akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n;
vector<string> s;
/*
bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second)
    {
        return a.first < b.first;
    }
    else
    {
        return a.second > b.second;
    }
}
*/
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;
        s.push_back(temp);
    }
    vector<int> close(n, 0);
    vector<int> open(n, 0);
    rep(i, n)
    {
        int count = 0;
        rep(j, s[i].size())
        {
            if (s[i][j] == ')')
            {
                if (count)
                {
                    count--;
                }
                else
                {
                    close[i]++;
                }
            }
            else
            {
                count++;
            }
        }
        open[i] = count;
    }
    //debug(open);
    //debug(close);
    vector<pair<int, int>> v;
    int ccount=0;
    int ocount=0;
    rep(i, n)
    {
        if(open[i]==0)ccount+=close[i];
        else if(close[i]==0)ocount+=open[i];
        else 
        v.push_back(make_pair(close[i]-open[i],i));
    }
    sort(ALL(v));
    int count=ocount;
    deque<int>d;
    rep(i,v.size()){
        while(!d.empty()){
            int j=d.front();
            if (count >= close[j])
            {
                d.pop_front();
                count -= close[j];
                count += open[j];
            }
            else break;
        }
        if(count<close[v[i].second]){
            d.push_back(v[i].second);
        }
        else{
            count -= close[v[i].second];
            count += open[v[i].second];
        }
    }
    if (d.empty() && count == ccount)
            yes;
        else
            no;
}


Measured memory_bytes: 42260
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, max=0;
  cin >> n;
  map<string, int> memo;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    memo[s]++;
  }
  for( auto& x: memo){
    int v = x.second;
    if(max < v){
      max = v;
    }
  }
  
  for(auto it = memo.begin(); it != memo.end(); it++){
    if(it->second == max){
      cout << it->first <<endl;
    }
  }
  
}


Measured memory_bytes: 25216
#include<stdio.h>
int main(){
  int a,b,c,d,n,i;
  while(scanf("%d",&n) != EOF){
    i=0;
    for(a=0;a<10;a++)
      for(b=0;b<10;b++)
	for(c=0;c<10;c++)
	  for(d=0;d<10;d++)
	    if(a+b+c+d==n)i++;
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;


int keta5(int64_t x){
  int count=0;
  while(x%5==0){
    x/=5;
    count++;
  }
  return count;
}
int keta2(int64_t x){
  int count=0;
  while(x%2==0){
    x/=2;
    count++;
  }
  return count;
}

//入力
int main() {
  int64_t N,ans=0; cin>>N;
  vector<vector<int64_t>> A(50,vector<int64_t>(50,0));
  rep(i,N){
    string s, u,v; cin>>s;
    bool p=true;
    int t=s.size();
    rep(j,t){
      auto w=s.at(j);
      if(w=='.') {
        p=false;
        continue;
      }
      if(p) u.push_back(w);
      else v.push_back(w);
    }
    while(v.size()<9) v.push_back('0');
    reverse(u.begin(),u.end());
    reverse(v.begin(),v.end());
    
    int64_t k=0, x=1;
    rep(j,v.size()){
      k+=x*(v.at(j)-'0');
      x*=10;
    }
    rep(j,u.size()){
      k+=x*(u.at(j)-'0');
      x*=10;
    }
    int a=keta2(k),b=keta5(k);
    A.at(a).at(b)++;
  }
  
//数え上げ
  rep(i,50){
    rep(j,50){
      rep(k,50){
        rep(l,50){
          auto t=A.at(i).at(j), m=A.at(k).at(l);
          if(i+k>17&&j+l>17){
            if(i==k&&j==l) ans+=t*(t-1);
            else ans+=t*m;
          }
        }
      }
    }
  }

//出力  
  cout<<ans/2;
  
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main()
{
	int n,i,j,f;
	char s[1000],t[]="Hoshino";
	scanf("%d\n",&n);
	while(n--)
	{
		gets(s);
		for(i=0;i<strlen(s);i++)
		{
			for(j=0,f=1;j<7;j++)
				if(t[j]!=s[i+j])
				{
					f=0;
					break;
				}
			if(f)
				s[i+6]='a';
		}
		puts(s);
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a >= 6 && a <= 12) {
            System.out.println(b / 2);
        } else if(a <= 5) {
            System.out.println(0);
        } else {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 21716
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };

int n, m, r;
ll dist[111111];
const ll INF = 1e13;
vector<P>G[111111];

int main() {
	cin >> n >> m >> r;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		G[a].pb(mp(b, c));
	}

	priority_queue<PP, vector<PP>, greater<PP> >bfs;

	rep(i, n)dist[i] = INF;
	bfs.push(mp(0, r));

	while (!bfs.empty()) {
		ll d = bfs.top().first, from = bfs.top().second;
		bfs.pop();
		if (dist[from] != INF)
			continue;

		dist[from] = d;
		for (int i = 0; i < G[from].size(); i++) {
			ll to = G[from][i].first, next_cost = d+G[from][i].second;
			bfs.push(mp(next_cost, to));
		}
	}
	rep(i, n) {
		if (dist[i] == INF)cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 16796
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#define debugf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define debug \
    if (0) cout
#define debugf(format, ...) 42
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

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

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int cnt1[] = { 0, 0, 0 }, cnt2[] = { 0, 0, 0 };
    const int MOD = 998244353;
    int ans = 1;
    for (char x : s) {
        int t = 0;
        if (x == 'G')
            t = 1;
        else if (x == 'B')
            t = 2;
        int p = (t + 1) % 3, q = (t + 2) % 3;
        if (cnt2[t]) {
            ans = 1LL * ans * cnt2[t] % MOD;
            --cnt2[t];
        } else if (cnt1[p]) {
            assert(cnt1[q] == 0);
            ans = 1LL * ans * cnt1[p] % MOD;
            ++cnt2[q];
            --cnt1[p];
        } else if (cnt1[q]) {
            ans = 1LL * ans * cnt1[q] % MOD;
            ++cnt2[p];
            --cnt1[q];
        } else {
            ++cnt1[t];
        }
    }
    for (int i = 1; i <= n; ++i) {
        ans = 1LL * ans * i % MOD;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
set<string>st;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string str;
        cin>>str;
        st.insert(str);
    }
    cout<<st.size()<<endl;
    return 0;
}


Measured memory_bytes: 19060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

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

int main() {
  vector<int> v(3);
  int n;
  while(cin>>v[0]>>v[1]>>v[2],v[0]+v[1]+v[2]) {
    cin >> n;
    sort(ALL(v));
    double d = sqrt(v[0]*v[0]+v[1]*v[1])/2;
    REP(i,n) {
      int r;
      cin >> r;
      if (d<r)
        cout << "OK";
      else
        cout << "NA";
      cout << endl;
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
    int num;
    cin >> num;
    int x[num];
    for(int i=0; i<num; i++){
        cin >> x[i];
    }
    for(int j=num-1; j>=0; j--){
        cout << x[j];
        if(j!=0){
            cout << " ";
        }

    }
    cout << "\n";
    return 0;
}


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

typedef pair<int,int> P;

int n, m;
int x[1005], y[1005], z[1005];

signed main(){
  
  cin>>n>>m;
  
  for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i];
  
  int ans = 0;
  
  for(int i=0;i<2;i++){
    
    for(int j=0;j<2;j++){
      
      for(int k=0;k<2;k++){
	
	priority_queue<P> Q;
	
	for(int l=0;l<n;l++){
	  
	  int value = 0;
	  
	  if( i == 0 ) value += x[l];
	  else value -= x[l];	  
	  
	  if( j == 0 ) value += y[l];
	  else value -= y[l];
	  
	  if( k == 0 ) value += z[l];
	  else value -= z[l];
	  
	  Q.push( P( value, l ) );
	  
	}
	
	int X = 0, Y = 0, Z = 0;
	
	for(int l=0;l<m;l++){
	  
	  P tmp = Q.top(); Q.pop();
	  
	  X += x[tmp.second];
	  Y += y[tmp.second];
	  Z += z[tmp.second];
	  
	}
	
	ans = max( ans, abs( X ) + abs( Y ) + abs( Z ) );
	
      }
      
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const S = arg[1].split("");
    
    const charset = new Set(S);
    const chars = [...charset];
    
    let answer = 0;
    
    for(let i in S) {
        const first = S.slice(0, i);
        const last  = S.slice(i, S.length);
        
        let temp = 0;
        
        for(let j in chars) {
            if(first.indexOf(chars[j]) !== -1 && last.indexOf(chars[j]) !== -1) {
                temp++;
            } 
        }
        
        // console.log(first);
        // console.log(last);
        // console.log("---");
        answer = Math.max(answer, temp);
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7884
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));
		StringBuffer sb = new StringBuffer();

		while(true) {
			String line = br.readLine();
			String[] strArray = line.split(" ");
			int[] intArray = new int[strArray.length];
			intArray[0] = Integer.parseInt(strArray[0]);
			intArray[1] = Integer.parseInt(strArray[1]);

			if (intArray[0] == 0 && intArray	[1] ==0) {
				break;
			}

			if (intArray[0] < intArray[1]) {
				sb.append(intArray[0]).append(" ").append(intArray[1]).append("\n");
			} else {
				sb.append(intArray[1]).append(" ").append(intArray[0]).append("\n");
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 26520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0;i<N;i++){
  cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  
  int x=1;
  for(int i=0;i<N-1;i++){
    if(d.at(i+1)>d.at(i)){
    x++ ;
    }
  }
  
  cout << x << endl;
  }
  
  

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

int main() {

  int N , M ,tot;
  cin >> N;
  cin >> M;
  vector<int> vec(N);

  
  for(int i=0; i<M; i++){
    cin >> vec.at(i);
    tot+=vec.at(i);
  }

  if(N-tot>=0){
    cout << N-tot << endl;
    
  }

  else{
    cout << "-1" << endl;
    }

  
}


Measured memory_bytes: 7220
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
PYI=sorted([(p,y,i) for i,(p,y) in enumerate(PY)])
r=['']*M
a,b=0,0
for p,y,i in PYI:
    if a!=p:
        a,b=p,1
    else:
        b+=1
    r[i]=str(p).zfill(6)+str(b).zfill(6)
print(*r,sep='\n')

Measured memory_bytes: 46072
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include<unordered_map>

using namespace std;

int main(void)
{
    long long n;
    cin >> n;
    long long sum = 0;
    vector<long long> a(n);
    map<long long, long long> cnt;
    cnt[0] = 1;
    long long ans = 0;
    for (long long i = 0; i < n;i++){
        cin >> a[i];
        sum += a[i];
        ans += cnt[sum];
        cnt[sum]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        var a = int.Parse(str[0]);
        var b = int.Parse(str[1]);
        var c = int.Parse(str[2]);
        var min = a + b;
        var t1 = a + c;
        if (min > t1) min = t1;
        var t2 = b + c;
        if (min > t2)
        {
            Console.Write("{0}", t2);
            return;
        }
        Console.Write("{0}", min);
    }
}

Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main(){int a,b,c,i,j;while(cin>>a>>b,a) {int d[20][20]={0};bool e[20][20]={0};cin>>c;while(c--){cin>>i>>j;e[i][j]=1;}d[1][1]=1;for(i=1;i<=a;i++){for(j=1;j<=b;j++){if(e[i][j])continue;d[i][j]+=d[i-1][j]+d[i][j-1];}}cout<<d[a][b]<<endl;}}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    string s;cin>>s;
    ll q;cin>>q;
    rep(i,q){
        string op;cin>>op;
        if(op=="print"){
            ll a,b;cin>>a>>b;
            cout<<s.substr(a,b-a+1)<<endl;
        }else if(op=="reverse"){
            ll a,b;cin>>a>>b;
            reverse(s.begin()+a,s.begin()+b+1);
        }else{
            ll a,b;cin>>a>>b;
            string p;cin>>p;
            s=s.replace(a,b-a+1,p);
        }
    }
}

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



Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=0; i<=N; i++){
        if(i%3!=0 && i%5!=0){
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(){
	
	int N,A[100010],i,ans=1,k=1;
	
	scanf("%d",&N);
	
	for(i=1;i<=N;i++){
		scanf("%d",&A[i]);
	}
	
	
	
	
	while(k<=N-1){
	if(A[k+1]>A[k]){
			if(k==N-1){
				printf("\n%d\n\n",ans);
				return 0;
			}
			
			for(i=1;i<=N-k-1;i++){
				if(A[k+1+i]<A[k+i]){
				k+=i+1;
				ans++;
				break;
			}
			
			if(k+i==N-1){
				printf("\n%d\n\n",ans);
				return 0;
			}
			
	}
	}else if(A[k+1]<A[k]){
		
		if(k==N-1){
				printf("\n%d\n\n",ans);
				return 0;
			}
			
			
			for(i=1;i<=N-k-1;i++){
				if(A[k+1+i]>A[k+i]){
				k+=i+1;
				ans++;
				break;
			}
			
			if(k+i==N-1){
				printf("\n%d\n\n",ans);
				return 0;
			}
	}
	}else if(A[k+1]==A[k]){
		k++;
		
	}
	}	
	
	printf("\n%d\n\n",ans);
	
	
	return 0;
}

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

int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  int num = 100 * r + 10 * g + b;
  if (num % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <math.h>

using namespace std;
#define ll long long

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main()
{
    //freopen("aa_input.txt", "r", stdin);
    int n;
    cin>>n;
    vector<pair<int, int>> v;
    int a, b;
    for(int i=0; i<n; i++){
        cin>>a>>b;
        v.push_back({a, b});
    }
    sort(v.begin(), v.end(), sortbysec);
    int sum = 0;
    bool ok = true;
    for(auto it:v){
        sum += it.first;
        if(sum>it.second){
            ok = false;
            break;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}
/*

riaadmorshed@gmail.com

*/

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 200002;
constexpr ll MOD = 998244353;

vector<int> divisors(int n) {
    vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i) continue;
        ret.push_back(i);
        if (i*i < n) ret.push_back(n/i);
    }
    sort(begin(ret), end(ret));
    return ret;
}

int val(string & s) {
    int res = 0;
    for (char c : s) ((res <<= 1) += c == '1') %= MOD;
    return res;
}

void inv(string & s) { for (char & c : s) c = '0'+'1'-c; }

int cnt[MN];

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; string X; cin >> N >> X;

    int ans = 0;
    for (int d : divisors(N)) {
        int m = N/d;
        if (m%2 == 0) continue;
        string s = X.substr(0, d);
        (cnt[d] += val(s)) %= MOD;

        string t, r = s; inv(r);
        for (int i = 0; i < m; ++i) i%2 == 0 ? t += s : t += r;
        if (t <= X) ++cnt[d] %= MOD;

        for (int j = 2*d; j <= N; j += d) if (N%j == 0) (cnt[j] += MOD-cnt[d]) %= MOD;
        (ans += 2ll*d*cnt[d]%MOD) %= MOD;
    }
    cout << ans;
}


Measured memory_bytes: 4260
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

long long n , m;

int main(){
    cin>>n>>m;
    if(n % m == 0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max({a, b, c});
    int x = 3 * mx - a - b - c;
    if (x % 2 == 0) {
        cout << x / 2 << endl;
    } else {
        cout << (x + 3) / 2 << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0067
{
	class Program
	{
		static	bool[,]	map	= new bool[ 12, 12 ];
		static	bool[,]	chk	= new bool[ 12, 12 ];
		
		
		static void Main(string[] args)
		{
			while( true ) {
				for( int y = 0; y < 12; y++ ) {
					for( int x = 0; x < 12; x++ ) {
						map[ y, x ]	= false;
						chk[ y, x ]	= false;
					}
				}
				
				for( int y = 0; y < 12; y++ ) {
					var	line = Console.ReadLine();
					for( int x = 0; x < 12; x++ ) {
						if( line[ x ] == '1' ) {
							map[ y, x ]	= true;
						}
					}
				}
				
				int	cnt	= 0;
				for( int y = 0; y < 12; y++ ) {
					for( int x = 0; x < 12; x++ ) {
						if( map[ y, x ] ) {
							if( chk[ y, x ] == false ) {
								cnt++;
								move_chk( y, x );
							}
						}		
					}
				}
				Console.WriteLine( cnt);

				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
			}
		}

		static void move_chk( int y, int x )
		{
			int[,]	offset	= {
				{  0, -1 },
				{  1,  0 },
				{  0,  1 },
				{ -1,  0 }
			};
			
			chk[ y, x ]	= true;

			for( int i = 0; i < 4; i++ ) {
				var	nx	= x + offset[ i, 0 ];
				var	ny	= y + offset[ i, 1 ];
				if( (nx >= 0) && (nx < 12) && (ny >= 0) && (ny < 12) ) {
					if( map[ ny, nx ] && (chk[ ny, nx ] == false) ) {
						move_chk( ny, nx );
					}
				}
			}
		}
	}
}

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

    sumA=sum(A)

    rsumA=A[0]

    res=0
    mod=pow(10,9)+7

    for i in range(len(A)-1):
        res+=A[i]*(sumA-rsumA)
        res=res%mod
        rsumA+=A[i+1]

    print(res)
if __name__=="__main__":
    main()

Measured memory_bytes: 94104
n = int(input())

s = []

for i in range(n):
    s.append(int(input()))

s = sorted(s)

total = 0
for i in range(n):
    total += s[i]

i = 0
while total > 0 and total%10 == 0:
    if s[i]%10 != 0:
        total -= s[i]
    i += 1
    if i == n:
        total = 0

print(total)

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

using namespace std;

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

    vector<int> ss(26);
    for(int i=0;i<s.size();i++){
        int tmp = s[i] - 'a';
        if(ss[tmp]==1){
            cout<<"no";
            return 0;
        }
        ss[tmp]++;
    }
    cout<<"yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ggd(long long number1,long long number2){
	long long m = number1;
	long long n = number2;

	if(number2 > number1){
		m = number2;
		n = number1;}
    long long tmp;
	do{
      tmp=m%n;
      m=n;
      n=tmp;
    } while(tmp!=0);
    return m;
}
int main(){
  long long A,B,C,D;
  cin >> A >> B >> C >> D;
  long long tmpc1=(A-1)/C;
  long long tmpc2=B/C;
  long long tmpd1=(A-1)/D;
  long long tmpd2=B/D;
  long long tmpcd1=(A-1)/(C*D/ggd(C,D));
  long long tmpcd2=B/(C*D/ggd(C,D));
  
  cout <<B-A+1+ tmpc1+tmpd1-tmpcd1-tmpc2-tmpd2+tmpcd2 << endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int a[n];
    int o[n]; //オリジナル
    rep(i, n)
    {
        cin >> a[i];
        o[i] = a[i];
    }
    sort(a, a + n);
    int index=a[0];
    int num=0;
    map<int, int> p; //数の数
    int com = 0;
    rep(i, n)
    {
        if(index==a[i]){
            num++;
        }
        else{
            p.insert(mp(index, num));
            if(num>1){
                com += combination(num, 2);
            }
            index = a[i];
            num = 1;
        }
    }
    p.insert(mp(index, num));
    if(num>1){
        com += combination(num, 2);
    }
    rep(i,n){
        cout << com - (p[o[i]] - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 14336
// https://atcoder.jp/contests/abc064/tasks/abc064_a
"use strict"
function Main(input) {
  const param = Number(input.split(' ').join(''));
  if(param % 4 === 0) {
    console.log('YES');
  } else {
    console.log('NO');
  }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N, M = [int(t) for t in input().split()]
a    = [int(t) for t in input().split()]
assert len(a) == N

def prefixsum(a):
    s = [0] * len(a)
    s[0] = a[0] % M
    for i in range(1, len(a)):
        s[i] = (s[i-1] + a[i]) % M
    return s

s = prefixsum(a)
t = [(s[i], i) for i in range(N)]
t.sort()

count = 0
prev = -1
c = 0
for v, i in t:
    if v == 0: count += 1
    if prev == v:
        c += 1
    else:
        count += c * (c - 1) // 2
        c = 1
        prev = v
count += c * (c - 1) // 2

print(count)

Measured memory_bytes: 21952
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
int a[200005];
int main() {
	int n;
	readin(n);
	for (int i = 1; i <= n; i ++) {
		readin(a[i]);
	}
	int res = 0;
	long long cnt = 0;
	for (int i = 1; i <= n; i ++) {
		if (res > a[i]) {
			cnt += 1ll * res - a[i]; 
		}
		else res = a[i];
	}
	writeln(cnt, '\n');
	return 0;
}




Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define PI 3.1415926535
#define N 10010
using namespace std;
int n, m;
int a, b, c;
int d[N];
int x ,y, w, h, r;
int p = 1;
int cnt = 0;
int main(){
    scanf("%d", &n);
    int min = 0x3f3f3f3f;
    int max = -min;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &d[i]);
        sum += d[i];
        if(d[i] < min) min = d[i];
        if(d[i] > max) max = d[i];

    }
    printf("%d %d %lld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 3244
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

bitset<2000*1000+1> bs;
int main() {
	int N;
	cin >> N;
	int sum=0;
	bs[0]=1;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		sum+=a;
		bs|=(bs<<a);
	}
	for(int i=sum/2;i>=0;i--){
		if(bs[i]){
			cout << sum-i << endl;
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int main(){
    int a;
    cin >> a;
    int ans = 0;
    int eight[5] = {105,165,195,135,189};
    for(int i = 0;i < 5;i++){
        if(eight[i] <= a)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  [n,k] <- map (read :: String -> Int) . words <$> getLine
  vn <- map (read :: String -> Int) . words <$> getLine
  print $ ans n k vn

ans :: Int -> Int -> [Int] -> Int
ans n k vn = maximum $ map (pickup n k vn) $ allComb n k

pickup :: Int -> Int -> [Int] -> (Int,Int) -> Int
pickup n k vn (a,b) = sum $ func 0 xs where
  p = k-a-b
  xs = sort $ (take a vn) ++ (drop (n-b) vn)
  func _ [] = []
  func m (l:ls)
    | m == p = l:ls
    | l >= 0 = l:ls
    | l < 0 = func (m+1) ls

allComb :: Int -> Int -> [(Int,Int)]
allComb n k = concat $ map func ms where
  func l = zip [0..l] [l,l-1..0]
  ms = [0..min n k]

Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<sstream>
#include<bitset>
#include<numeric>
#include<math.h>

using namespace std;
using ll = long long int;

vector<int> sw;
vector<int> s[10], p, kk;
int n, m;

vector<int> dfs(int a) {
	vector<int> ret;
	stringstream ss;
	ss << bitset<10>(a);
	string tmp = ss.str();
	for (int i = 10 - n; i < 10; i++) {
		ret.push_back(int(tmp[i]) - int('0'));
	}
	return ret;
}

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int ki;
		cin >> ki;
		kk.push_back(ki);
		for (int j = 0; j < ki; j++) {
			int sij;
			cin >> sij;
			s[i].push_back(sij-1);
		}
	}

	for (int j = 0; j < m; j++) {
		int pj;
		cin >> pj;
		p.push_back(pj);
	}

	sw = vector<int>(n, 0);
	int ret = 0;
	for (int i = 0; i < pow(2, n); i++) {
		sw = dfs(i);
		bool flag = true;
		for (int j = 0; j < m; j++) {
			int tmp = 0;
			for (int k = 0; k < kk[j]; k++) {
				tmp += sw[s[j][k]];
			}
			if (tmp % 2 != p[j]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ret++;
		}
	}
	cout << ret << endl;
	return 0;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w, k := intScanner(), intScanner(), intScanner()
	c := make([]string, h)
	for i := 0; i < h; i++ {
		c[i] = Scanner()
	}
	ans := 0
	for i := 0; i < (1 << uint(h)); i++ {
		for j := 0; j < (1 << uint(w)); j++ {
			count := 0
			for k := 0; k < h; k++ {
				for l := 0; l < w; l++ {
					if (i>>uint(k))&1 == 0 && (j>>uint(l))&1 == 0 {
						if string(c[k][l]) == "#" {
							count++
						}
					}
				}
			}
			if count == k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
use std::cmp::Reverse;
use std::cmp::max;
use std::collections::VecDeque;
use std::cmp::min;
use std::collections::BTreeSet;
use std::cmp::Ordering;
use std::fmt::Debug;

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
        buffer.clear();
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.trim().parse().ok().expect("Can't Parse"));
        buffer.clear();
    }
    vec
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };
}
macro_rules! read {
    (mut $ident: ident: [$ty:ty]) => {
        let mut $ident = read_values::<$ty>();
    };
    ($ident: ident: [$ty:ty]) => {
        let $ident = read_values::<$ty>();
    };
    ($($token: tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        read_from_iter!(iter; $($token)*);
    };
}
macro_rules! read_from_iter {
    ($iter:expr; mut $ident:ident:$ty:ty, $($rest:tt)*) => {
        let mut $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
        read_from_iter!($iter; $($rest)*);
    };
    ($iter:expr; $ident:ident:$ty:ty, $($rest:tt)*) => {
        let $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
        read_from_iter!($iter; $($rest)*);
    };
    ($iter:expr; mut $ident:ident:$ty:ty) => {
        let mut $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
    };
    ($iter:expr; $ident:ident:$ty:ty) => {
        let $ident = $iter.next().unwrap().parse::<$ty>().expect("Can't Parse");
    };
    ($iter: expr; ) => {};
}
struct KeyValue<K, V> {
    key: K,
    value: V
}
impl <K: PartialOrd, V> PartialEq for KeyValue<K, V> {
    fn eq(&self, other: &Self) -> bool {
        self.key.eq(&other.key)
    }
}
impl <K: PartialOrd, V> Eq for KeyValue<K, V> {}
impl <K: PartialOrd, V> PartialOrd for KeyValue<K, V> {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        self.key.partial_cmp(&other.key)
    }
}
impl <K: PartialOrd, V> Ord for KeyValue<K, V> {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.key.partial_cmp(&other.key).ok_or("Can't Compare").unwrap()
    }
}

fn main() {
    read!(x: i64);
    let mut time = 1i64;
    let mut current = 1i64;
    while current < x { 
        time += 1;
        current += time;
    }
    println!("{}", time);
}


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> xs(n), ls(n);
	for (int64_t i = 0; i < n; i++)
	{
		cin >> xs[i] >> ls[i];
	}

	{
		vector<pair<int64_t, int64_t>> as(n);
		for (int64_t i = 0; i < n; i++)
		{
			as[i] = {xs[i], ls[i]};
		}

		sort(as.begin(), as.end(), [](auto &l, auto &r) {
			return l.first + l.second < r.first + r.second;
		});

		for (int64_t i = 0; i < n; i++)
		{
			xs[i] = as[i].first;
			ls[i] = as[i].second;
		}
	}

	vector<int64_t> dp(n + 1, 0);
	for (int64_t i = 0, j = 0; i < n; i++)
	{
		while (j < n && xs[j] - ls[j] < xs[i] + ls[i])
		{
			j++;
		}

		dp[j] = max(dp[j], dp[i] + 1);
	}

	cout << *max_element(dp.begin(), dp.end()) << endl;

	return 0;
}

Measured memory_bytes: 3328
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll a,b;
    cin >> a >> b;

    if(a<=8 && b<=8){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
n, a, b, c, d = map(lambda x:int(x)-1,input().split())
n += 1
S = input()

ok = True
overtake = False

if c < d:
    overtake = True
    
for i in range(a,d):
    if S[i] == "#" and S[i+1] == "#":
        ok = False

for i in range(b,min(d+1,n-1)):
    if S[i] == "." and S[i-1] == "." and S[i+1] == ".":
        overtake = True
        
if ok and overtake:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 67888
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
#define TMP template<typename
// #define DEBUG
#ifdef DEBUG
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
#endif

typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define F first
#define S second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define frb(i,j, n) for (auto (i) = (j); (i) >= (n); (i)--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define ra(a) for(int &x : (a)) in(x)
#define pa(a) for(int &x : (a)) cout << (x) << " ";cout << "\n"
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

/*----------fast input-------------*/
#define ff
#ifdef ff
TMP T>
inline void in(T &x)
    {
    register T c = getchar_unlocked();
    x = 0;
    T neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }

#else
TMP... T>
void in(T&... args){
((cin >> args) , ...);
}
#endif
/*----------check constraints again-------------*/
int a[100005];
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  in(n);
  fri(i,0,n) in(a[i]);
  frb( i ,n-1 , 1){
      if(a[i-1] > a[i]){
          if(a[i-1]-1 == a[i]) {a[i-1]-=1; continue;}
          else cout << "No"; return 0;
      }
    //   if( !(a[i] >= (a[i-1]-1))) {cout << "No";return 0;}
  }

  cout << "Yes";
  return 0;
}

// 4
// 1 3 2 1

Measured memory_bytes: 640
#include<iostream>
#include<string.h>

using namespace std;

int main(){
  string a;
  cin >> a;
  
  if(a[0] == a[1] && a[0] ==a[2] ||a[1] == a[2] && a[1] ==a[3] ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }


//-----------------------
int main() {
	
	long res = 0;
	long N; cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];

	for (int i = 0; i < N; i++) sort(S[i].begin(), S[i].end());
	sort(S.begin(), S.end());

	long p = 1;
	for (int i = 1; i < N; i++) if (S[i - 1] == S[i]) p++; else { res += p * (p - 1) / 2; p = 1; }
    res += p * (p - 1) / 2;
 
	cout << res << endl;
}

Measured memory_bytes: 7296
using System;
using System.Linq;

namespace ConsoleApp3
{
    internal class Class2
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(" ").Select(decimal.Parse).ToArray();
            var a = x[0];
            var b = x[1];
            var c = x[2];
            var d = x[3];

            Console.WriteLine(Math.Max(Math.Max(a * c, b * d), Math.Max(a * d, b * c)));
        }
    }
}

Measured memory_bytes: 28304
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

struct Napsack_multino{
    int C;
    int N;
    pair<int,int> *prods;
    int *dp;
    int prod_count; 
    Napsack_multino(int c,int n){
      	C=c;N=n;
        prods = new pair<int,int>[N];
        prod_count=0;
        dp = new int[(C+2)*(N+2)*2];
      	initdp();
    }
    int mkitr(int x,int y,int n){
        return x*(C+1)+y+(C+1)*(N+1)*n;
    }
    void initdp(){
        rep(i,N+1){
            rep(j,C+1){
                rep(k,2){
                    dp[mkitr(i,j,k)]=0;
                }
            }
        }
    }
    void push_prods(int c,int p){
        prods[prod_count++]=mp(c,p);
    }
    int solve(){
        initdp();
        rep(i,N+1){
            if(i>0)rep(j,C+1){
                //まだ最後のを使ってない
                dp[mkitr(i,j,0)]=dp[mkitr(i-1,j,0)];
                if(j>0)dp[mkitr(i,j,0)]=max(dp[mkitr(i,j,0)],dp[mkitr(i,j-1,0)]);
                int p=prods[i-1].second;int c=prods[i-1].first;
                if(j-c>=0)dp[mkitr(i,j,0)]=max(dp[mkitr(i,j,0)],dp[mkitr(i-1,j-c,0)]+p);
                //もう最後のを使ったもしくはちょうど使う
                dp[mkitr(i,j,1)]=dp[mkitr(i-1,j,1)];
                if(j>0)dp[mkitr(i,j,1)]=max(dp[mkitr(i,j,1)],dp[mkitr(i,j-1,1)]);
                //もう使ったのでそのまま
                if(j-c>=0)dp[mkitr(i,j,1)]=max(dp[mkitr(i,j,1)],dp[mkitr(i-1,j-c,1)]+p);
                //まだ使ってないので無料使う
                c=0;
                if(j-c>=0)dp[mkitr(i,j,1)]=max(dp[mkitr(i,j,1)],dp[mkitr(i-1,j-c,0)]+p);
            }
        }
        return dp[mkitr(N,C,1)];
    }
    void debug_printdp(){
        rep(i,N+1){
            rep(j,C+1){printf("%lld ",dp[mkitr(i,j,0)]);}
            printf("\n");
        }
    }
    void free_(){
        delete[] prods;
        delete[] dp;
    }
    
};


int MOD=1000000007;
int N,T;
int A[3005],B[3005];
char S[1000];
signed main(){
    scanf("%lld %lld",&N,&T);
    rep(i,N){
        scanf("%lld %lld",&A[i],&B[i]);
    }
    
    int ans=0;
    Napsack_multino NP(T-1,N);
    rep(i,N){
        NP.push_prods(A[i],B[i]);
    }
    ans=NP.solve();
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 141056
import java.util.*;

class Main{
public static void main(String[] args) {
  Scanner reader=new Scanner(System.in);
  int n=reader.nextInt();
  int m=reader.nextInt();
  Integer a[]=new Integer[n];
  int sum=0;

  for(int i=0;i<n;i++)
  {
    a[i]=(Integer)reader.nextInt();
    sum+=a[i];

  }
  Arrays.sort(a,Collections.reverseOrder());

  for(int i=0;i<m;i++)
  {
    if(a[i]*4*m<sum){
    System.out.println("No");
    return;
  }

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

  }
}

Measured memory_bytes: 23124
#include<iostream>

using namespace std;
int main(){
    int s;
    cin>>s;
    
    int i=1;
    if(s==2||s==1){
        i=1;
    }
    else{
    while(s !=4){

       if(s%2==0){
        s=s/2;
        i++;
       }
       else{
           s=(s*3+1);
       i++;
       }
       }}
    int ans=i+3;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int judge(int num){
    int i;
    for(i=2;i<num;i++){
        if(i*i > num)
            return 0;
        if(num % i == 0)
            return 1;
    }
    return 0;
}
 
int main(void){
    int n,i,sum=0;
    int  a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(judge(a) == 0)
            sum++;
    }
printf("%d\n",sum);
return 0;
}


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

using namespace std;

bool is_palindrome(string s)
{
    string s1 = s;
    reverse(s1.begin(), s1.end());

    return s1 == s;
}

string s;
void read()
{
    cin >> s;
}

void solve()
{
    if (!is_palindrome(s))
    {
        cout << "No" << endl;
        return;
    }

    int n = s.size();
    if (!is_palindrome(s.substr(0, n / 2)) || !is_palindrome(s.substr(n / 2 + 1, n / 2)))
        cout << "No" << endl;

    else
        cout << "Yes" << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 256