akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> alph(26, 0);
    vector< vector<bool> > used = vector< vector<bool> >(55, vector<bool>(55, false));
    for(int i=0;i<n;i++) cin >> s[i];

    for(int i=0;i<26;) {
        bool flag = true;
        for(int j=0;j<n;j++) {
            bool f = false;
            for(int k=0;k<s[j].size();k++) {
                //cout << s[j][k] << endl;
                if(!used[j][k] && s[j][k] == ('a' + i)) {
                    //alph[i]++;
                    used[j][k] = true;
                    f = true;
                    break;
                }
            }
            if(!f) {
                flag = false;
                break;
            }
        }
        if(!flag) {
            i++;
        }
        else {
            alph[i]++;
        }
    }
    
    for(int i=0;i<26;i++) {
        for(int j=0;j<alph[i];j++) {
            cout << (char) (i+'a');
        }
    }
    cout << endl;


}


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

int A[100010];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  
  map<int, int> mp;
  for (int i = 0; i < N; i++) mp[A[i]]++;
  
  int how_many_times, ans = 0;
  
  for (auto p: mp) {
    how_many_times = p.second;
    if (how_many_times % 2 == 1) ans++;
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<std::vector<int64_t>> a(n, std::vector<int64_t>(n));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      std::cin >> a[i][j];
    }
  }

  int64_t len = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      bool flag = true;
      for (int k = 0; k < n; k++) {
        if (i == k || j == k) {
          continue;
        }
        if (a[i][j] == a[i][k] + a[k][j]) {
          flag = false;
        }
        if (a[i][k] + a[k][j] < a[i][j]) {
          std::cout << -1 << std::endl;
          return 0;
        }
      }
      if (flag) {
        len += a[i][j];
      }
    }
  }

  std::cout << len << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W;
    cin >> H >> W;
    vector<string>S(H);
    int cnt = 0;
    for(int i = 0; i < H; i++) {
        cin >> S[i];
        for(int j = 0; j < W; j++) {
            if(S[i][j] == '#') {
                cnt++;
            }
        }
    }
    queue<P> que;
    que.push({0,0});
    vector<vector<int>>count(H,vector<int>(W,INF));
    count[0][0] = 0;
    while(!que.empty()) {
        P X = que.front();
        que.pop();
        for(int i = 0; i < 4; i++) {
            int nx = X.first+dx[i];
            int ny = X.second+dy[i];
            if(nx >= 0 && nx < H && ny >= 0 && ny < W) {
                if(S[nx][ny] == '.') {
                    if(count[nx][ny] == INF) {
                        que.push({nx,ny});
                        count[nx][ny] = count[X.first][X.second]+1;
                    }
                }
            }
            if(nx == H-1 && ny == W-1) {
                cout << H*W-count[nx][ny]-cnt-1 << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}


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

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

  int n = s.size();
  int ans = INT_MAX;
  for(int i = 0;i < n-2;i++){
    ans = min(ans, abs(753-((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0'))));
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a] += [b]
  graph[b] += [a]

cnt = [0] * N
for _ in range(Q):
  p, x = map(int, input().split())
  p -= 1 
  cnt[p] += x

def dfs(u, pre):
  for v in graph[u]:
    if v != pre:
      cnt[v] += cnt[u]
      dfs(v, u)
  return

dfs(0, -1)
print(*cnt)

Measured memory_bytes: 230960
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		
		
		while(true){
			int n = sc.nextInt();
			if(n == 0){break;}
			list.clear();
			for(int i = 0; i < n; i++){
				list.add(sc.nextInt());
			}
			
			int max_num = Integer.MIN_VALUE;
			for(int i = 0;i < n;i++){
				int sum = 0;
				for(int j = i;j < n;j++){
					sum += list.get(j);
					if(max_num < sum){
						max_num = sum;
					}
				}
			}
			
			System.out.println(max_num);
		
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >>N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    double AAA=vec.at(0);
    double sum=AAA;
    for(int i=1;i<N;i++){
        sum=(sum+vec.at(i))/2;
    }
    cout << sum <<endl;


}

Measured memory_bytes: 3724
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

class MaxSegTree {
public:
    // create a MaxSegTree instance with minimal size 
    // actual size will be adjusted to a power of 2
    MaxSegTree(int size) {
        int actualSize = 1;
        while (actualSize < size) actualSize *= 2;
        nodes.resize(actualSize * 2 - 1, 0);
    }

    // return the number of leafs allowed in this container
    int size() {
        return (nodes.size() + 1) / 2;
    }

    void setAt(int i, LL v) {
        int index = leafIndex(i);
        nodes[index] = v;
        while (0 < index) {
            index = (index - 1) / 2;
            nodes[index] = max(nodes[2 * index + 1], nodes[2 * index + 2]);
        }
    }

    LL maxInRange(int begin, int end) {
        return maxInRangeImpl(begin, end, 0, 0, (nodes.size()+1) / 2);
    }

    void dumpTree() {
        int index = 0;
        for (int size = 1;; size *= 2) {
            rep(i, size) { 
                if (nodes.size() <= index) {
                    cout << endl;
                    return;
                }
                cout << nodes[index] << ' ';
                ++ index;
            }
            cout << endl;
        }
    }

private:
    //! index 0: [0..2^n)
    //! index 1: [0..2^(n-1))
    //! index 2: [2^(n-1)..2^n-1)
    //! parent-index of node at i = (i-1)/2
    //! indexes of children of node at i = 2i + 1, 2i + 2
    //! index of i-th leaf node = i + 2^(n-1) -1 = i + actualSize - 1

    int leafIndex(int i) { return i + size() - 1; }

    LL maxInRangeImpl(int begin, int end, int segIndex, int segBegin, int segEnd) {
        if (end <= segBegin || segEnd <= begin) {
            return 0; //! the range and the segment do not have intersection
        }
        if (begin <= segBegin && segEnd <= end) {
            //! the range is completely included in the segment
            return nodes[segIndex];
        }
        return max( maxInRangeImpl(begin, end, 2 * segIndex + 1, segBegin, (segBegin + segEnd)/2), 
                    maxInRangeImpl(begin, end, 2 * segIndex + 2, (segBegin + segEnd)/2, segEnd) );
    }

    vector<LL> nodes;
};


int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    vector<int> a(N);
    rep(i, N) cin >> h[i];
    rep(i, N) cin >> a[i];

    MaxSegTree segTree(N+1);

    vector<LL> dp(N); //! max values up to flower i
    rep(i, N)  {
        dp[i] = segTree.maxInRange(0, h[i]) + a[i];
        segTree.setAt(h[i], dp[i]);
    }

    cout << segTree.maxInRange(1, N+1) << endl;

    return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll a, b, ans = 0;
    cin >> a >> b;
    if(a > b) {
        ans += a;
        a--;
        ans += max(a, b);
    }
    else {
        ans += b;
        b--;
        ans += max(a, b);
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N,Q;
    string s;
    int l[100010],r[100010];
    int a[100010];
    cin>>N>>Q;
    cin>>s;
    for(int i=0;i<Q;i++){
        cin>>l[i]>>r[i];
    }
    int cnt=0;
    a[0]=0;
    a[1]=0;
    for(int i=1;i<N;i++){
        if(s[i-1]=='A' && s[i]=='C'){
                cnt++;
                a[i+1]=cnt;
        }
        else {a[i+1]=cnt;}
        //cout<<a[i+1]<<endl;
    }
    for(int i=0;i<Q;i++){
        if(s[l[i]-2]=='A' && s[l[i]-1]=='C'){
            cout<<a[r[i]]-a[l[i]-1]-1<<endl;
        }
        else cout<<a[r[i]]-a[l[i]-1]<<endl;
    }



    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int A, B;
    cin >> A >> B;
    if ((A & 1) && (B & 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*100100 for _ in range(110)]

for i in range(N):
    for sum_w in range(W+1):
        weight, value = item[i]
        if sum_w - weight >= 0:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - weight] + value)

        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])

print(dp[N][W])

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

int N,M;
struct edge{ int from,to,cost; };

vector< edge > G[100000];

map<int,bool> visited;
map<int,int> d;

bool dfs(int pos,int sum){
  if(visited[pos]){
    if( d[pos] == sum )return true;
    else return false;
  }
  visited[pos]=true;
  d[pos]=sum;
  for(int i=0;i<(int)G[pos].size();i++){
    edge e=G[pos][i];
    if( !dfs(e.to, sum+e.cost) )return false;
  }
  return true;
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int L,R,D;
    cin>>L>>R>>D;
    L--,R--;
    G[L].push_back( (edge){L,R, D} );
    G[R].push_back( (edge){R,L,-D} );
  }

  bool ans=true;
  for(int i=0;i<N;i++){
    if(visited[i])continue;
    if( !dfs(i,0) ){
      ans=false;
      break;
    }
  }
  cout<< (ans?"Yes":"No") <<endl;
  return 0;
}


Measured memory_bytes: 25344
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    internal static class CR
    {
        public static string GetText() { return Console.ReadLine(); }
        public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long GetLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
    }

    public class Program
    {
        public static long L { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            L = CR.GetLong();

            return Math.Pow((double)L / 3, 3);
        }
    }
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    
    vector<bool> B(n + 1);
    B[0] = true;
    for (int i = 0; i < n; i++){
        if (B[A[i] - 1])
            B[A[i]] = true;
    }

    int k;
    for (int i = n; i >= 0; i--){
        if (B[i]){
            k = i;
            break;
        }
    }

    cout << (k == 0 ? -1 : n - k) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_129A(){
    int array[3];
    REP(i,3) cin >> array[i];

    sort(array, array+3);
    cout << array[0] + array[1] << endl;
}

int main(void){
    solve_129A();
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double one = 1;
double p[3000],dp[3000][3000];
double probablity(int h,int n)
{
	if(h<0)
		return 0;
	if(h>n || n==0)
	{
		return 0;
	}
	if(dp[h][n]!=-1)
	{
		return dp[h][n];
	}
	
	if(n>1)
	{
		dp[h][n] = (one-p[n])*probablity(h,n-1) + p[n]*probablity(h-1,n-1);
		return dp[h][n];
	}
	else
	{
		if(h==0)
		{
			dp[h][n] = one-p[n];
			return one-p[n];
		}
		else
		{
			dp[h][n] = p[n];
			return p[n];
		}
	}
}
int main()
{
	int n;
	double ans=0;
	cin>>n;
	for (int i = 0; i < 3000; ++i)
	{
		for(int j = 0; j < 3000 ;j++)
		{
			dp[i][j] = -1;
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		cin>>p[i];
	}
	for(int j = n/2+1; j <= n ;j++)
	{
		ans += probablity(j,n);
	}
	printf("%.10f\n",ans );
	
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
using namespace std;
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }

    if(n >= m){
        pr(0);
        return 0;
    }

    SORT(x);
    vector<int> diff(m - 1);
    for (int i = 0; i < m-1; i++) {
        diff[i] = (x[i+1] - x[i]);
    }
    RSORT(diff);

    int ans = x[x.size() - 1] - x[0];

    REP(i, n - 1){
        ans -= diff[i];
    }
    pr(ans);
}

Measured memory_bytes: 1024
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int countP(string S){
    int count = 0;
    rep(i,S.length())if(S[i]=='p') count++;
    return count++;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(S);
    int gMinusP = 0;
    int point = 0;
    rep(i,S.length()){
        if(gMinusP<=0){
            gMinusP++;
            if(S[i]=='p')point--;
        }else{
            if(S[i]=='g'){
                gMinusP--;
                point++;
            }else{
                gMinusP--;
            }
        }
    }
    cout << point << nn;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()


void COUT(vector<vector<long>> &mat){
    long s = mat.size();
    rep(i,s){
        rep(j,s){
            cout << mat.at(i).at(j) << " ";
        }
        cout << endl;
    }
    cout << endl;
}

void Initmat(vector<vector<long>> &mat,long n){
    for(int i=1;i<n;i++){
        mat.at(i).at(i-1) = 1;
    }
}

void multmat(vector<vector<long>> &ret,vector<vector<long>> mat1,vector<vector<long>> mat2){
    long m = mat1.size();
    rep(i,m){
        rep(j,m){
            long tmp = 0;
            rep(k,m){
                tmp += mat1.at(i).at(k) * mat2.at(k).at(j);
                tmp %= MOD;
            }
            ret.at(i).at(j) = tmp;
        }
    }
}

vector<vector<long>> matpow(vector<vector<long>> mat,long num){
    long k = mat.size();
    //cout << k << endl;
    vector<vector<long>> ret(k,vector<long>(k,0));
    rep(i,k) ret.at(i).at(i) = 1;
    //COUT(ret);
    bitset<60> bt(num);
    rep(i,60){
        if(bt.test(i)){
            multmat(ret,ret,mat);
            //COUT(ret);
        }
        multmat(mat,mat,mat);
    }
    return ret;
}


int main(){
    long n,k;
    cin >> n >> k;
    vector<vector<long>> mat(n,vector<long>(n));
    rep(i,n){
      rep(j,n) cin >> mat[i][j];
    }
    vector<vector<long>> ret = matpow(mat,k);
    long ans = 0;
    rep(i,n){
      rep(j,n) {
        ans += ret[i][j];
        ans %= MOD;
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

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

// 65 65  65 65
int main()
{
	ll x;
	cin >> x;
	ll cnt = x / 11;
	if (x % 11 == 0)
	{
		cout << cnt * 2 << endl;
	}
	else if (x % 11 > 6)
	{
		cout << (cnt * 2 + 2) << endl;
	}
	else
	{
		cout << (cnt * 2 + 1) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a > b)
    {
        swap(a, b);
    }
    if (a != 0)
    {
        return gcd(b % a, a);
    }
    else
    {
        return b;
    }
}
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    vector<int> left_sum(N), right_sum(N);
    left_sum[0] = A[0];
    right_sum[0] = A[N - 1];
    for (int i = 1; i < N; i++)
    {
        left_sum[i] = gcd(left_sum[i - 1], A[i]);
        right_sum[i] = gcd(right_sum[i - 1], A[N - i - 1]);
    }
    reverse(right_sum.begin(), right_sum.end());
    // for (int i = 0; i < N; i++)
    // {
    //     cout << "left_sum" << left_sum[i] << endl;
    //     cout << "right_sum" << right_sum[i] << endl;
    // }
    vector<int> calc(N);
    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            calc[0] = right_sum[1];
        }
        else if (i == N - 1)
        {
            calc[N - 1] = left_sum[N - 2];
        }
        else
        {
            calc[i] = gcd(left_sum[i - 1], right_sum[i + 1]);
        }
    }
    int ans = *max_element(calc.begin(), calc.end());
    //for (int i = 0; i < N; i++)
    //{
    //    cout << "calc" << calc[i] << endl;
    //}
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main()
{
    int L,R;
    cin >> L >> R;

    if(L/2019!=R/2019 || L%2019==0 || R%2019==0)
    {
        cout << '0' << endl;
    }
    else
    {
        vector<ll> V(2039190,1000000001);
        int counter = 0;
        for(ll i=L;i<R;i++)
        {
            for(ll j=i+1;j<=R;j++)
            {
                V.at(counter) = (i*j)%2019;
                counter++;
            }
        }
        ll minV = *min_element(V.begin(),V.end());
        cout << minV << endl;
    }
    return 0;
}

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

struct rectangle {int pos, height;};

int main() {
    int h, w;
    cin >> h;
    cin >> w;
    int tile[h+1][w+1];
    int dp[h+1][w+1];
    int max_area = 0;
    rep(i, h+1) {
        stack<rectangle> s;
        rep(j, w+1) {
            if (i == 0 || j == w) {
                dp[i][j] = 0;
            } else {
                cin >> tile[i][j];
                if (tile[i][j] == 0) {
                    dp[i][j] = dp[i-1][j] + 1;
                } else {
                    dp[i][j] = 0;
                }
            }
            if (s.empty() && dp[i][j] != 0) {
                s.push({j, dp[i][j]});
            } else if (not s.empty() && s.top().height < dp[i][j]) {
                s.push({j, dp[i][j]});
            } else if (not s.empty() && s.top().height > dp[i][j]) {
                int left;
                while (not s.empty() && s.top().height >= dp[i][j]) {
                    int area = (j - s.top().pos) * s.top().height;
                    max_area = max(max_area, area);
                    left = s.top().pos;
                    s.pop();
                }
                if (dp[i][j] != 0) {
                    s.push({left, dp[i][j]});
                }
            }
        }
    }
    // rep(i, h+1) {
    //     rep(j, w+1) {
    //         printf("%d ", dp[i][j]);
    //     }
    //     printf("\n");
    // }
    cout << max_area << endl;
}


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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  for(int i=a; i<=b; i++){
    if(i%k==0){
      cout <<"OK"<<endl;
      return 0;
    }
  }
  cout << "NG" << endl;
      return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    auto ok = [&](ll t) {
                  ll cnt = 0;
                  rep(i, n) {
                      ll nokori = max(0LL, h[i] - b * t);
                      cnt += (nokori + a-b - 1) / (a-b);
                  }
                  return cnt <= t;
              };
    ll l = 0, r = 1e9;
    while (r - l > 1) {
        ll mid = (l + r) >> 1;
        if (ok(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 3940
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
using namespace std;

int main () {
  long long n;
  vector<pair<long long, long long> > ab;
  vector<pair<long long, long long> > cd;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long s, ss;
    cin >> s >> ss;
    ab.push_back(make_pair(s, ss));
  }  
  for (long long i = 0; i < n; i++) {
    long long s, ss;
    cin >> s >> ss;
    cd.push_back(make_pair(s, ss));
  }  
  sort(ab.begin(), ab.end());
  sort(cd.begin(), cd.end());
  int score[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (ab[i].first < cd[j].first &&
          ab[i].second< cd[j].second) {
        score[i][j] = 1;  
      }  
      else {
        score[i][j] = 0;  
      }
    }  
  }
  int ans = 0;
  map<int, int> jj;
  bool ok = true;
  while (1) {
    int min = -1;
    int it = -1;
    ok = true;
    for (int i = 0; i < n; i++) {
      int nn = 0;
      for (int j = 0; j < n; j++) {
        if (score[i][j] == 1) {
          ok = false;
          nn++;
        }    
      }  
      if (nn > 0) {
        if (nn < min || min < 0) {
          min = nn;
          it = i;  
        }
      }
    }    
    if (ok == true) {
      break;  
    }
    int jt;
    for (int j = 0; j < n; j++) {
      int nn = 0;
      for (int i = 0; i < n; i++) {
        if (score[i][j] == 1) {
          nn++;
        }    
      }  
      jj[j] = nn;
    }    
    min = -1;
    for (int j = 0; j < n; j++) {
      if (score[it][j] == 1) {
        //ans++;
        //score[it][j] = 0;
        //jt = j;
        //break;
        if (min < 0 || min > jj[j]) {
          jt = j;
          min = jj[j];  
        }
      }  
    }
    score[it][jt] = 0;
    ans++;
    for (int j = 0; j < n; j++) {
      score[it][j] = 0;  
    }
    for (int i = 0; i < n; i++) {
      score[i][jt] = 0;  
    }
  }
  cout << ans << endl;
}

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

struct node
{
	int id;
	int time;
}stu[100010];

bool cmp(node a,node b)
{
	return a.time<b.time;
}

int main()
{
	int N;
	cin>>N;
	for (int i=1;i<=N;i++)
	{
		stu[i].id=i;
		cin>>stu[i].time;
	}
	sort(stu+1,stu+N+1,cmp);
	for (int i=1;i<=N;i++)
		cout<<stu[i].id<<" ";
	cout<<endl;
} 

Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>


using namespace std;

double dp[1<<13][13];
int n;


int main(){

    
    
    
    

    string input;
    while(getline(cin, input)){
        stringstream ss;
        ss<<input;
        double box;
        ss>>box;
        
        double cake[12]={0};
        n=0;
        while(ss>>cake[n]){
            n++;
        }
        
        double v[13][13]={0};
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i==j){
                    v[i][j]=0;
                    v[j][i]=v[i][j];
                }else{
                    double x = (cake[i]+cake[j])*(cake[i]+cake[j])-(cake[i]-cake[j])*(cake[i]-cake[j]);
                    v[i+1][j+1]=sqrt((fabs(x)));
                    //cout<<i<<" "<<j<<" "<<v[i][j]<<endl;
                    v[j][i]=v[i][j];
                }
                
            }
        }
        
        for(int i=1; i<=n; i++){
            v[0][i]=cake[i-1];
            v[i][0]=cake[i-1];
        }
        
        
        n++;
        //memset(dp, 999999.9999, sizeof(dp));
        for(int i=0; i<(1<<13); i++){
            for(int j=0; j<13; j++){
                dp[i][j]=100000000;
            }
        }
        
        
        dp[(1<<n) - 1][0] = 0;

        
        for(int i=(1<<n)-2; i>=0; i--){
            for(int j=0; j<n; j++){
                for(int k=0; k<n; k++){
                    if(!((i >> k) & 1)){
                        
                        
                        dp[i][j] = min(dp[i][j], dp[i | (1 << k)][k] + v[j][k]);
                        
                    }
                }
            }
        }
        
        //cout<<dp[0][0]<<endl;
        if(dp[0][0]<=box)cout<<"OK"<<endl;
        else cout<<"NA"<<endl;

        
        
        
        
    }
}

Measured memory_bytes: 2072
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),m = sc.nextInt();
    int a[]=new int[n];
    int sum=0;
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      sum+=a[i];
    }
    Arrays.sort(a);
    boolean flg=true;
    for(int i=0;i<m;i++){
      if(a[n-i-1]<sum/4.0/m){
        flg=false;
        break;
      }
    }
    if(flg){
      pl("Yes");
    }else{
      pl("No");
    }
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 24276
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}

ll facts[100010],invs[100010];

signed main(){
    int n = 100000;
    ll f = 1;
    facts[0] = 1;
    FOR(i,1,n+1){
        f *= i;
        f %= mod;
        facts[i] = f;
    }
    ll inv = powll(f,mod-2);
    invs[n] = inv;
    REPNS(i,n){
        inv *= i;
        inv %= mod;
        invs[i-1] = inv;
    }

    int k;
    vi a;
    cin >> n >> k;
    a.resize(n);
    REP(i,n) cin >> a[i];
    sort(all(a));

    int ans = 0;
    REP(i,n-k+1){
        int temp = a[n-1-i];
        temp = temp * facts[n-1-i] % mod * invs[k-1] % mod * invs[n-i-k] % mod;
        ans = (ans + temp + mod) % mod;
        // cerr << n-1-i << " " << ans << endl;

        temp = -a[i];
        temp = temp * facts[n-1-i] % mod * invs[k-1] % mod * invs[n-i-k] % mod;
        ans = (ans + temp + mod) % mod;
        // cerr << i << " " << ans << endl;

    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
N, K = map(int, input().split())

def prepare(N, MOD):
    fac = [None] * (N+2)
    finv = [None] * (N+2)
    inv = [None] * (N+2)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, N+1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
    return fac, finv

def comb_rem(N, K, fac, finv, MOD):
    if N < K:
        return 0
    if N < 0 or K < 0:
        return 0
    else:
        return fac[N] * (finv[K] * finv[N - K] % MOD) % MOD

MOD = 10 ** 9 + 7

for i in range(1, K+1):
    ans = 1
    fac, finv = prepare(N-K+1, MOD)
    a = comb_rem(N-K+1, i, fac, finv, MOD)
    fac, finv = prepare(K-1, MOD)
    b = comb_rem(K-1, i-1, fac, finv, MOD)
    ans *= a * b % MOD
    print(ans)

Measured memory_bytes: 48604
#!python3.4
# -*- coding: utf-8 -*-
# abc156/abc156_b
import sys
import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    print(len(np.base_repr(N, K)))
    return

main()


Measured memory_bytes: 21240
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
class water {
public:
	int w;
	int s;
};

bool operator<(water &a, water &b) {
	float r1 = (float)a.s / (a.w + a.s);
	float r2 = (float)b.s / (b.w + b.s);
	return r1 < r2;
}

int find(int num, vector<char> &list) {
	int res = 0;
	for (int i = num; i > 0; --i) {
		if (list[i]) {
			res = i;
			break;
		}
	}
	return res;
}
int main() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	vector<char> sugar(f + 1, false);
	sugar[0] = true;
	for (int i = 0; i < f - c; ++i) {
		if (sugar[i]) {
			sugar[i + c] = true;
		}
	}
	for (int i = 0; i < f - d; ++i) {
		if (sugar[i]) {
			sugar[i + d] = true;
		}
	}
	vector<char> list(f + 1, false);
	list[a] = list[b] = true;
	water ans;
	ans.s = -100;
	ans.w = 1000;
	for (int i = min(a,b); i <= f; ++i) {
		if (list[i]) {
			water res;
			res.w = i;
			res.s = find(min(i / 100 * e, f - i), sugar);
			if (ans < res) {
				ans = res;
			}
			if (i + a <= f) {
				list[i + a] = true;
			}
			if (i + b <= f) {
				list[i + b] = true;
			}
		}
	}
	cout << ans.w + ans.s << " " << ans.s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(a * b / 2);
        sc.close();
    }
}

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

int main()
{
  int p = 700;
  string s;
  cin >> s;
  if(s[0] == 'o') p = p + 100;
  if(s[1] == 'o') p = p + 100;
  if(s[2] == 'o') p = p + 100;
  cout<< p <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

/*

??£???????¨????

ax+by=c
dx+ey=f

????§£???x, y ???????????????????????°?????????????????????????????????a, b, c, d, e, f ??????
???????????? -1,000 ??\??? 1,000 ??\???????????°??¨????????£???????¨????????§£?????????????????¨
??????????????????????????????????????¨????????????

Input
?????°???????????????????????????????????????????????\?????????????????§????????????????????????1??????
?????????????????????1???????????????????????????1??????????????????????????? a, b, c, d, e, f 
???1????????????????????§????????????????????????????????????

Output
????????????????????????????????????x, y ???1????????????????????§????????£???1?????????????????????
???????????????????°???°?????\????¬¬3????????§?????????????????????????°???°?????\????¬¬4???????????¨???
??\??????????????????

*/

//
//	??£???2???????¬?????¨????(?????\??° x, y????????° a, b, c, d, e, f )
//	
//		ax + by = c
//		dx + ey = f
//	
//	?§£
//
//		x = ( c * e - b * f ) / ( a * e - b * d )
//		y = ( f * a - c * d ) / ( a * e - d * b )



int main( void )
{
	int a, b, c, d, e, f;
	
	double x, y;
	
	while ( scanf( "%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f ) != EOF ) {
		
		x = ( double )( c * e - b * f ) / ( double )( a * e - b * d );
		y = ( double )( f * a - c * d ) / ( double )( a * e - d * b );
		
		if ( x == 0 ) {
			x = 0;
		}
		if ( y == 0 ) {
			y = 0;
		}
		
		printf( "%.3lf %.3lf\n", x, y );
	
	}
	
	return 0;
}

Measured memory_bytes: 1824
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter     out                    = new PrintWriter(outputStream);
        TaskA             solver                = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int i = N / 111;
            if(N % 111 != 0) {
            	i++;
            }
            System.out.println(i * 111);
           
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    N = int(input())
    primes = defaultdict(int)
    ans = 0
    for i in range(1, N + 1):
        k = i
        for j in range(2, i+1):
            if j ** 2 > i: break
            if k % j == 0:
                while k % j == 0:
                    primes[j] += 1
                    k //= j
        if k > 1: primes[k] += 1
    P = []
    for key in primes: P.append(primes[key])
    pn = len(P)

    for i in range(pn):
        if P[i] >= 74: ans += 1
        if P[i] >= 24:
            for j in range(pn):
                if P[j] >= 2 and j != i: ans += 1
        if P[i] >= 14:
            for j in range(pn):
                if P[j] >= 4 and j != i: ans += 1
        if P[i] >= 4:
            for j in range(i+1, pn):
                if P[j] >= 4:
                    for k in range(pn):
                        if P[k] >= 2 and k != i and k != j: ans += 1
    print(ans)
    #print(primes)
    #print(P)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
s = input()
t = input()
lt = len(t)
ls = len(s)
A = []
for i in range(ls-lt+1):
    cou = 0
    for j in range(lt):
        if s[i+j] == t[j]:
            cou += 1
    A.append(cou)
print(lt-max(A))

Measured memory_bytes: 73252
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  string s;
  string mo="";

  cin >>s;

  int n = s.length();

  rep(i,n){
    if(s[i]=='0'){
      mo+='0';
    }
    else if(s[i]=='1'){
      mo+='1';
    }
      else{
      if(mo!="")
      {mo.replace((mo.length()-1),1,"");}
    }
  }
  cout << mo <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, X, M, S = 0;
    cin >> N >> X >> M;
    vector<pair<int, int>> memo(M);
    REP(i, N) {
        // 循環した初回のみループ変数iを最終ループまで飛ばす
        if (memo[X].first) {
            // ループ間の長さ
            int t = i - memo[X].first;
            // ループが繰り返される回数
            int c = (N - i - 1) / t;
            i += t * c;
            S += (S - memo[X].second) * c;
        } else {
            memo[X] = {i, S};
        }
        S += X;
        X = X * X % M;
    }
    cout << S << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 4716
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int n,sum=0,sumy=0;
	while (1){
		sum = 0;
		sumy = 0;
		cin >> n;
		if (n == 0)break;
		int ma[101][101] = { 0 };
		for (int i = 0; i < n; i++){
			sum = 0;
			for (int i2 = 0; i2 < n; i2++){
				cin >> ma[i][i2];
				sum += ma[i][i2];

			}
			sumy += sum;
			ma[i][n] += sum;
		}
		ma[n][n] += sumy;
		for (int i = 0; i < n; i++){
			sum = 0;
			for (int i2 = 0; i2 < n; i2++){
				sum += ma[i2][i];
				sumy += sum;
			}
			ma[n][i] += sum;
		}
		n++;
		for (int i = 0; i < n; i++){
			for (int i2 = 0; i2 < n; i2++){
				printf("%5d", ma[i][i2]);
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1232