akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	while(N--){
		string a,b;
		cin >> a >> b;
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		while(a.size()>b.size())b += '0';
		while(a.size()<b.size())a += '0';
		string r;
		int c = 0; 
			for(int i = 0 ; i < a.size() ; i++){
			int d = a[i] + b[i] + c - 2 * '0';
			if( d >= 10 ) c = 1;
			else c = 0;
			r += d%10 + '0';
		}
		if(c)r += '0' + c;
		reverse(r.begin(),r.end());
		if( r.size() > 80 ) cout << "overflow" << endl;
		else cout << r << endl;
	}
}

Measured memory_bytes: 2968
#include <stdio.h>
int main()
{
    int a, b, sum;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if(op=='+'){
    sum = a + b;
    printf("%d\n", sum);
    }
    else if(op=='-'){
    sum = a-b;
    printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sc(x) scanf("%d", &x)
#define sc2(x, y) scanf("%d%d", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define sc4(x, y, z, t) scanf("%d%d%d%d", &x, &y, &z, &t)
#define print(x) printf("%d ", x)
#define println(x) printf("%d\n", x)
#define println2(x, y) printf("%d %d\n", x, y)
#define println3(x, y, z) printf("%d %d %d\n", x, y, z)
#define println4(x, y, z, t) printf("%d %d %d %d\n", x, y, z, t)
#define mp make_pair
#define pb push_back
#define ft first
#define sd second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define endl '\n'                           // CommentInInteractive
#define DB(x) cerr << #x << " = " << x << endl

const ld eps = 1e-6;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;

void solve() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 10001; ++i) {
        if ((floor(i * 0.08) == a && floor(i * 0.1) == b) ||
                (floor(i * 0.08) == b && floor(i * 0.1) == a)) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

//#define FILES
//#define TIME

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

#ifdef FILES
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    auto start = chrono::high_resolution_clock::now();
    solve();
    auto stop = chrono::high_resolution_clock::now();

#ifdef TIME
    cerr << chrono::duration_cast <chrono::milliseconds> (stop - start).count() << " ms\n";
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#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;

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

    const double PI = 3.141592;
    
    int R;
    cin >> R;

    double ans = 2.0 * PI * R;

    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n,m;
  cin >> n >> m;
  vector<vector<LL>> nei(n);
  REP(i,m) {
    LL x,y;
    cin >> x >> y;
    x %= n;
    y %= n;
    nei[x].push_back(y);
  }
  LL s,t;
  cin >> s >> t;
  s %= n;
  t %= n;
  priority_queue<pair<LL,LL>> q;
  q.emplace(0,s);
  vector<LL> cost(n*3,-3ll);
  while(!q.empty()) {
    LL nc,pos;
    tie(nc,pos) = q.top(); q.pop();
    if(cost[pos]!=-3) continue;
    cost[pos] = -nc;
    for(auto x:nei[pos%n]) {
      q.emplace(nc-1,(-(nc-1))%3*n+x);
    }
  }
  cout << cost[t]/3 << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
int main(){
    int r;
    cin >> r;
    double pi = 3.14159265359;
    double a = 2*pi*r;
    printf("%.2f",a);
    return 0;
}







Measured memory_bytes: 3764
#include<stdio.h>
int main(){
  int N,cnt=0,i,min;
  scanf("%d",&N);
  char S[N+1];
  scanf("%s",S);
  
  for(i=0;i<N;i++){
    if(S[i]=='.')cnt++;
  }
  if(S[0]=='.'){
    cnt--; 
    min=cnt;
  }
  else {
    min=cnt; 
    cnt++;
  }

  for(i=1;i<N;i++){
    if(S[i]=='.')cnt--;
    else cnt++;
    if(cnt<min){
      min=cnt;
    }
  }
  printf("%d\n",min);
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;

string check(string s){
    ll len = s.size();
    vector<bool> res(len, false);
    
    if(s[len-1] == s[1])    res[0] = true;
    else                    res[0] = false;
    if(s[0] == 'W') res[0] = !res[0];

    for(ll i = 1; i < len-1; i++){
        if(s[i-1] == s[i+1])    res[i] = true;
        else                    res[i] = false;
        if(s[i] == 'W') res[i] = !res[i];
    }

    if(s[len-2] == s[0])    res[len-1] = true;
    else                    res[len-1] = false;
    if(s[len-1] == 'W') res[len-1] = !res[len-1];

    string str = "";
    rep(i, len) str += (res[i]? 'o':'x');

    return str;
}

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

    vector<string> list(4, "");
    list[0] += "SS";
    list[1] += "SW";
    list[2] += "WS";
    list[3] += "WW";

    for(ll i = 1; i < n-1; i++){
        rep(j, 4){
            if(s[i] == 'o'){
                if(list[j][i] == 'S'){
                    if(list[j][i-1] == 'S') list[j] += "S";
                    else                    list[j] += "W";
                }
                else{
                    if(list[j][i-1] == 'S') list[j] += "W";
                    else                    list[j] += "S";
                }
            }
            else{
                if(list[j][i] == 'S'){
                    if(list[j][i-1] == 'S') list[j] += "W";
                    else                    list[j] += "S";
                }
                else{
                    if(list[j][i-1] == 'S') list[j] += "S";
                    else                    list[j] += "W";
                }
            }
        }
    }

    rep(j, 4){
        if(s == check(list[j])){
            cout << list[j] << endl;
            return 0;
        }
    }

    cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <sstream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
// ll binaryNum[64];
// void decToBinary(ll n, ll k) 
// { 
//     // binaryNum[64]={0};
//     rep(i,64){
//         binaryNum[i]=0;
//     }
//     int i = 0; 
//     while (n > 0) { 
//         binaryNum[i] = n % k; 
//         n = n / k; 
//         i++; 
//     } 
// }
ll dp[2001][2001]; 
ll countPartitions(ll n, ll k) 
{   
    if (n < k) 
        return 0;
    if (n < 2 * k) 
        return 1; 
    if (dp[n][k] >= 0) 
        return dp[n][k]; 
    ll answer = 1; 
    for (int i = k; i < n; i++) 
        answer = answer + countPartitions(n - i, k); 
    dp[n][k] = answer%mod; 
    return answer%mod; 
} 


void solve(){
    ll n;
    cin >> n;
    // ll dp[n+1][n+1];
    // rep(i,n+1){
    //     dp[0][i]=1;
    //     dp[1][i]=0;
    //     dp[2][i]=0;
    //     dp[i][1]=0;
    //     dp[i][2]=0;
    //     dp[i][0]=0;
    // }
    // ll ans[n+1];
    // rep(i,n+1){
    //     rep(j,i){
    //         ans[i] += ans[j] + ans[j-i]; 
    //     }
    // }
    // cout<<n;
    for (int i = 0; i < n + 1; i++) { 
        for (int j = 0; j < n + 1; j++) { 
            dp[i][j] = -1; 
        } 
    } 
    cout<<countPartitions(n,3);
}


int main()
{

    // cout<<1<<endl;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 37308
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	vint x, y;
	int v = 0;
	rep(i, n) {
		if (abs(a[v]) < abs(a[i]))	v = i;
	}
	rep(i, n) {
		if (a[v] < 0 && a[i] > 0) {
			a[i] += a[v];
			x.push_back(v + 1);	y.push_back(i + 1);
		}
		if (a[v] > 0 && a[i] < 0) {
			a[i] += a[v];
			x.push_back(v + 1);	y.push_back(i + 1);
		}
	}
	if (a[v] > 0) {
		srep(i, 1, n) {
			if (a[i - 1] > a[i]) {
				a[i] += a[i - 1];
				x.push_back(i);	y.push_back(i + 1);
			}
		}
	}
	else {
		RREP(i, n - 2) {
			if (a[i] > a[i + 1]) {
				a[i] += a[i + 1];
				x.push_back(i + 2);	y.push_back(i + 1);
			}
		}
	}
	int m = x.size();
	cout << m << endl;
	rep(i, m)	cout << x[i] << " " << y[i] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int a[] = new int[100001];

		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}

		int SEG_SIZE = 100;
		int seg[] = new int[a.length/SEG_SIZE];
		int gcdInSegWithout[] = new int[100001];

		for(int i = 0; i < n; i += SEG_SIZE){
			int tmpgcd = a[i];

			int segID = i / SEG_SIZE;
			for(int j = 0; j < SEG_SIZE; j++){
				if(segID*SEG_SIZE + j >= n){
					break;
				}


				tmpgcd = gcd(a[segID*SEG_SIZE + j], tmpgcd);
			}
			seg[segID] = tmpgcd;
		}
//
//		for(int i = 0; i < 10; i++){
//			System.out.print(seg[i]+" ");
//		}
//		System.out.println();

		for(int i = 0; i < n; i ++){
			int tmpgcd = 0;

			int segID = i / SEG_SIZE;
			for(int j = 0; j < SEG_SIZE; j++){
				if(segID*SEG_SIZE + j >= n){
					break;
				}

				if(segID*SEG_SIZE + j == i){
					continue;
				}

				if(tmpgcd == 0){
					tmpgcd = a[segID*SEG_SIZE + j];
				}
				else {
					tmpgcd = gcd(a[segID*SEG_SIZE + j], tmpgcd);
				}
			}
			gcdInSegWithout[i] = tmpgcd;
		}
//		for(int i = 0; i < 10; i++){
//			System.out.print(gcdInSegWithout[i]+" ");
//		}
//		System.out.println();

		int result = 0;
		for(int i = 0; i < n; i++){

			int segID = i / SEG_SIZE;
			int tmpgcd = gcdInSegWithout[i];

			for(int j = 0; j < seg.length; j++){
				if(j == segID || seg[j] == 0){
					continue;
				}

				if(tmpgcd == 0){
					tmpgcd = seg[j];
				}
				else {
					tmpgcd = gcd(tmpgcd, seg[j]);
				}
			}

			result = Math.max(result, tmpgcd);
		}

		System.out.println(result);

	}

	static int gcd(int a, int b){
    	int tmp;

    	while (a % b != 0)
    	{
    		tmp = b;
    		b = a % b;
    		a = tmp;
    	}
    	return b;
    }
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n,d;
	cin>>n>>d;
    cout<<(n+d*2)/(d*2+1);
	return 0;
}

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

int main() {
  long long N,a,b,c,d,e;
  cin >> N >> a >> b >> c >> d >> e;
  
  vector<long long> vec = {a,b,c,d,e};
  sort(vec.begin(), vec.end());
  
  if(vec[0] >= N){
    cout << 5 << endl;
  }else{
    long long n = N/vec[0];
    if(N%vec[0]!=0){
      cout << 5+n << endl;
    }else{
      cout << 4+n << endl;
    }
  }
}

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

int main(){
  int n,ans,maxo=0,maxe=0,cnto,cnte;cin>>n;
  vector<int> ve(100001,0),vo(100001,0);
  REP(i,n){
    int tmp;cin>>tmp;
    if(i%2) vo.at(tmp)++;
    else ve.at(tmp)++;
  }
  REP(i,100001){
    if(vo.at(i)>maxo) maxo=vo.at(i),cnto=i;
    if(ve.at(i)>maxe) maxe=ve.at(i),cnte=i;
  }
  if(cnto!=cnte) ans=n-maxo-maxe;
  else{
    sort(ve.begin(),ve.end(),greater<int>());
    sort(vo.begin(),vo.end(),greater<int>());
    ans=min(n-vo.at(0)-ve.at(1),n-ve.at(0)-vo.at(1));
  }  
  cout<<ans;
}

Measured memory_bytes: 1024
def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    last=[0]*27
    ans=[]
    for i in range(1,d+1):
        a=0
        for j in range(1,27):
            a-=c[j-1]*(i-last[j])
        pa=0
        mlast=[0]*2
        for t in range(1,27):
            if s[i-1][t-1]+c[t-1]*(i-last[j])>pa:
                mlast=[t,i]
                pa=s[i-1][t-1]+c[t-1]*(i-last[j])
        a+=pa
        last[mlast[0]]=mlast[1]           
        ans.append(mlast[0])
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

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

#define all(v) v.begin(), v.end()
typedef long long ll;

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A){
    if(A.size() == n + 1){
        int sum = 0;
        for(int i = 0; i < q; i++){
            if(A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}


int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int N=18,inf=0x1f1f1f1f;
int a[N],b[N],f[1<<N][55];
int main(){
	int n,s;scanf("%d",&n),s=(1<<n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int i=0;i<n;i++)scanf("%d",b+i);
	memset(f,0x1f,sizeof(f));
	for(int i=0;i<=50;i++)f[0][i]=0;
	for(int i=1;i<s;i++){
		int w=0,w1=0;
		for(int j=0;j<n;j++)if(i&(1<<j))w++;
		for(int j=0;j<n;j++){
			if(!(i&(1<<j)))continue;
			if((w-j)&1)f[i][a[j]]=min(f[i][a[j]],f[i^(1<<j)][a[j]]+j-w1);
			else f[i][b[j]]=min(f[i][b[j]],f[i^(1<<j)][b[j]]+j-w1);
			w1++; 
		}
		for(int j=1;j<=50;j++)f[i][j]=min(f[i][j],f[i][j-1]);
	}
	printf("%d",f[s-1][50]==inf?-1:f[s-1][50]);
	return 0;
}

Measured memory_bytes: 56576
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] counts = new int[N + 1];
		
		boolean[] is_prime = new boolean[N + 1];
		Arrays.fill(is_prime, true);
		is_prime[0] = is_prime[1] = false;
		//System.out.println(Arrays.toString(is_prime));
		
		for(int i = 2; i <= N; i++){
			if(!is_prime[i]){ continue; }
			
			is_prime[i] = true;
			counts[i]++;
			//System.out.println(i);
			
			for(int j = i * 2; j <= N; j += i){
				is_prime[j] = false;
				
				//System.out.println(i + " " + j);
				for(int k = j; k > 1; k /= i){ 
					if(k % i != 0){ break; }
					counts[i]++;
				}
				//System.out.println(counts[i]);
			}
		}
		
		//System.out.println(Arrays.toString(is_prime));
		//System.out.println(Arrays.toString(counts));
		
		long answer = 1;
		for(int i = 0; i <= N; i++){
			if(counts[i] <= 0){ continue; }
			
			answer *= (counts[i] + 1);
			answer %= 1000000007;
		}
		
		System.out.println(answer);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 8148
s = str(input())
list = [int(i) for i in s]
cnt = 0
for i in range(len(list)-1):
  if list[i] == list[i+1] and list[i+1] == 0:
    list[i+1] = 1
    cnt += 1
  elif list[i] == list[i+1] and list[i+1] == 1:
    list[i+1] = 0
    cnt += 1
print(cnt)

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    int mi = 1000000;
    int ma = -1000000;
    long long int s = 0;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if (mi > a[i]){
            mi = a[i];
        }
        
        if (ma < a[i]){
            ma = a[i];
        }  
        s = s + a[i];
    }
    
    cout << mi << " " << ma << " " << s << endl;
 
//  cout <<  << endl;
//  printf("%f\n",x);
}


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

int main(void){
  int n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    if(i % 3 == 0) continue;
    if(i % 5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3552
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		if (i == 3 || i == 5 || i == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21972
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  char alpha, ans;
  cin >> alpha;
  if(65 <= alpha && alpha <= 90){
    ans = 'A';
  }else{
    ans = 'a';
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;




int main(){
	llint n;
	cin>>n;
	vector <llint> h(n+1), dp(n+1, INF);
	dp[0] = 0;
	loop(i, n){
		cin>>h[i+1];
	}
	dp[1] = 0;
	dp[2] = dp[1] + abs(h[2] - h[1]);
	//debug(dp[2]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	//	debug(dp[i]);
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

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

    vector<int> x(n);
    int sum=0;
    for(auto &y:x){
        cin >> y;
        sum+=y;
    }

    int p=sum/n;
    ll ansx=0;
    for(int i=0;i<n;i++){
        int diff=abs(x[i]-p);
        ansx+=diff*diff;
    }

    p++;
    ll ansy=0;
    for(int i=0;i<n;i++){
        int diff=abs(x[i]-p);
        ansy+=diff*diff;
    }

    ll ans=min(ansx,ansy);
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

#define ll long long
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main(){
  int h, n, w, ws;
  cin >> h >> n;
  REP(i, n){
    cin >> w;
    ws += w;
  }
  if (ws >= h) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 256
import math
n,d = map(int, input().split())
x = []
for i in range(n):
  x.append(list(map(int, input().split())))

s = 0
for i in range(n-1):
  a = x[i]
  for j in range(i+1, n):
    b = x[j]
    c = 0
    for j in range(d):
      c += abs(a[j] - b[j])**2
    if math.sqrt(c).is_integer():
      s += 1

print(s)

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

void max_replace(int &a, int b) {
    if (a < b) {
        a = b;
    }
    return;
}

int main() {
    string s, t;
    cin >> s >> t;
    int N = s.size(), M = t.size();

    vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (s.at(i - 1) == t.at(j - 1)) {
                max_replace(dp.at(i).at(j), dp.at(i - 1).at(j - 1) + 1);
            }
            max_replace(dp.at(i).at(j), dp.at(i - 1).at(j));
            max_replace(dp.at(i).at(j), dp.at(i).at(j - 1));
        }
    }

    string ans = "";
    while (N > 0 && M > 0) {
        if (dp.at(N).at(M) == dp.at(N - 1).at(M)) {
            N--;
        }
        else if (dp.at(N).at(M) == dp.at(N).at(M - 1)) {
            M--;
        }
        else {
            ans = s.at(N - 1) + ans;
            N--;
            M--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        ans += (s[i] == t[i] ? 0 : 1);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3868
#!/usr/bin/env pypy3

import math

h1, m1, h2, m2, k = map(int, input().split())

if h2 < h1:
    h2 += 24

if m2 < m1:
    h2 -= 1
    m2 += 60

allMin = (h2 - h1) * 60 + (m2 - m1)

res = allMin - k
if res < 0:
    res = 0

print(res)


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

using ll = long long;

template<typename T> bool chmax(T& x, T y) {if (x < y) {x = y; return true;} else {return false;}}

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    rep(i, n) {
        rep(j, W+1) {
            chmax(dp[i+1][j], dp[i][j]);
            if (j + w[i] <= W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 83068
import itertools

n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for i in range(n)]
count = 0
min_total=100000000

for i in range(2 ** n):
    subtotal = 0
    tmp_rikaido=[0]*m
    for j in range(n):
        if (i >> j) & 1:
            subtotal+=book[j][0]
            for k in range(m):
                tmp_rikaido[k] += book[j][k + 1]
                if all(a >= x for a in tmp_rikaido):
                    count += 1
                    if min_total > subtotal:
                        min_total=subtotal

if count == 0:
    print(-1)
else:
    print(min_total)

Measured memory_bytes: 9220
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
    ll l;
    cin>>n>>m>>l;
    ll d[303][303];
    const ll INF=1e18;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) d[i][j]=0;
            else d[i][j]=INF;
        }
    }
    for(int i=0; i<m; i++){
        int a, b, c;
        cin>>a>>b>>c;
        a--; b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    ll d2[303][303];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) d2[i][j]=0;
            else d2[i][j]=INF;
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i==j) continue;
            if(d[i][j]<=l) d2[i][j]=1;
        }
    }
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                d2[i][j]=min(d2[i][j], d2[i][k]+d2[k][j]);
            }
        }
    }
    int q; cin>>q;
    for(int i=0; i<q; i++){
        int s, t;
        cin>>s>>t;
        s--; t--;
        if(d2[s][t]==INF) cout<<-1<<endl;
        else cout<<d2[s][t]-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void solve(int N, vector<int> A, vector<int> B) {
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] != B[i]) {
      cnt += 1;
    }
  }
  if (cnt == 0 || cnt == 2) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A[i] = x;
    B[i] = x;
  }
  sort(B.begin(), B.end());
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  SORT(s);
  vector<int> count(n);
  count[0] = 1;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1])
      count[i + 1] = count[i] + 1;
    else
      count[i + 1] = 1;
  }
  int mmax = 0;
  for (int i = 0; i < n; i++) {
    mmax = max(mmax, count[i]);
  }
  for (int i = 0; i < n; i++) {
    if (mmax == count[i]) cout << s[i] << endl;
  }
}

Measured memory_bytes: 15104
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<ll> posi, nega;
	int z = 0;
	rep(i, n)
	{
		ll x; cin >> x;
		if (x > 0)posi.push_back(x);
		else if (x == 0)++z;
		else nega.push_back(abs(x));
	}
	int posiNum = posi.size();
	int negaNum = nega.size();
	ll MOD = 1e9 + 7;
	//負数になる場合
	if (!z && ((posiNum == 0 && k % 2 == 1) || (n == k && negaNum % 2 == 1)))
	{
		ll res = 1;
		sort(all(posi));
		sort(all(nega));
		for (ll x : posi)
		{
			res *= x;
			res %= MOD;
			--k;
		}
		rep(i, k)
		{
			res *= nega[i];
			res %= MOD;
		}
		cout << MOD - res << endl;
	}
	//正数になる場合
	else if(posiNum + (negaNum / 2) * 2 >= k)
	{
		if (posiNum == 0 && k % 2 == 1)
		{
			cout << 0 << endl;
			return 0;
		}
		sort(all(posi), greater<ll>());
		sort(all(nega), greater<ll>());
		int usedNegaNum = 0;
		int usedPosiNum = k;
		for (; usedNegaNum + 2 <= negaNum && usedPosiNum - 2 >= 0; usedNegaNum += 2, usedPosiNum -= 2)
		{
			if (usedPosiNum > posiNum)continue;
			ll nextNega = nega[usedNegaNum] * nega[usedNegaNum + 1];
			ll nextPosi = posi[usedPosiNum - 1] * posi[usedPosiNum - 2];
			if (nextPosi >= nextNega)break;
		}
		ll res = 1;
		rep(i, usedPosiNum)
		{
			res *= posi[i];
			res %= MOD;
		}
		rep(i, usedNegaNum)
		{
			res *= nega[i];
			res %= MOD;
		}
		cout << res << endl;
	}
	else cout << 0 << endl;
}

Measured memory_bytes: 5440
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,dp[100001][3];
int main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c;
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]});
}

Measured memory_bytes: 1408
n = int(input())
t,a = map(int,input().split())
s = list(map(int,input().split()))
m = 10**9
ans = 0
for i in range(n):
  c = abs(a - (t - s[i]*0.006))
  if m>c:
    m = c
    ans = i+1
print(ans)    

Measured memory_bytes: 3064
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second)return a.second < b.second;
    else return a.first < b.first;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>>v(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a>> b;
        v[i].first = a;
        v[i].second = b;
    }
    sort(v.begin(), v.end(), compare_by_b);

    int last = 0;
    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (v[i].first <= last&&last < v[i].second)continue;
        else {
            last = v[i].second - 1;
            ans++;
        }
    }

    cout << ans << endl;
    
}

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

const ld pi = acosl(-1);

int main()
{
    cout << fixed << setprecision(10);
    ld a, b, x;
    cin >> a >> b >> x;
    if(x < a * a * b / 2){
        ld c = x * 2 / a / b;
        cout << atan2(b, c) / pi * 180 << endl;
    }
    else{
        ld c = (a * a * b - x) * 2 / a / a;
        cout << atan2(c, a) / pi * 180 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int x,y,z;
    while(~scanf("%d%d%d",&z,&x,&y))
    {
        double a,b;
        a=fabs(z-x);
        b=fabs(z-y);
        if(a<=b) printf("A\n");
        else if (a>b) printf("B\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n , k;
	cin >> n >> k;

	loop(i,1,n+1)cin >> A[i];

	vector<string> vec;

	loop(i,k+1,n+1)
	{
		// cout << A[i] << " " << A[i-k] << endl;
		if(A[i] > A[i-k])vec.pb("Yes");
		else vec.pb("No");
	}

	loop(i,0,(int)(vec.size()))
	{	
		cout << vec[i] << endl;
	}
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 13004
#include <cstdio>
#include <cstring>

const int maxn=100;

char s[maxn+2];
int have[2][30],ans,n;

int main()
{
  scanf("%d%s",&n,s+1);
  for(int i=1; i<n; ++i)
    {
      memset(have,0,sizeof have);
      int cnt=0;
      for(int j=1; j<=i; ++j)
        {
          have[0][s[j]-'a'+1]=1;
        }
      for(int j=i+1; j<=n; ++j)
        {
          have[1][s[j]-'a'+1]=1;
        }
      for(int j=1; j<=26; ++j)
        {
          if(have[0][j]&&have[1][j])
            {
              ++cnt;
            }
        }
      if(cnt>ans)
        {
          ans=cnt;
        }
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string t, p;
    cin >> t;
    cin >> p;

    t += "$";
    p += "$";

    vector<bool> exists(p.size());
    bool duplicated = false;
    int i = 0;
    char tmp = '!';
    // P: aab, T: aaab ??????????????´???, ????????? a ??? OK ??????, 2????????? a ???????????????
    for (char j : t) {
        // ?????¨??????????????????????????¨?????´??????, ????????????????????????????????£????????????
        if (p[i] == j && !exists[i]) {
            exists[i] = true;
            // ?????????????´¢?????????????????????
            tmp = p[i];
            i += 1;
        }
        // ???????????????
        else if (tmp == j) {
            duplicated = true;
        }
    }

    if (accumulate(begin(exists), end(exists), true, logical_and<>())) {
        if (!duplicated) {
            cout << "yes" << endl;
            return 0;
        }
    }
    cout << "no" << endl;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
int main() 
{  
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
    long long int A;
    long long int B;
    cin>>A>>B;
    int count=0;
    if(A/2019==0)
        count=1;
    long long int ans=INT_MAX;
    count+=B/2019-A/2019;
    if(count>1)
    {  
        cout<<0<<endl;
        return 0;
    }
    for(long long int i=A;i<=B;i++)
    {
        for(long long int j=i+1;j<=B;j++)
        {
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    test_b();
}



fn test_b() {
    let s: String = read();
    let mut count: u16 = 0;
  for _x in 0..s.len()/2 {
      let a = s.chars().nth(_x);
      let b = s.chars().nth(s.len() - _x - 1);
      if a != b {
        count += 1;
      }
    }
    println!("{}", count);
}


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



const int N = 1e5 + 5, INF = 2e9;




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




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 2; i <= n; i++){
        dp[i] = INF;
        for(int j = 1; j <= k && i - j >= 1; j++){
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }
    cout << dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

struct cake{
    int w,h;
    int area;
    cake(int aw,int ah){
        w = aw;
        h = ah;
        area = w*h;
    }
};

bool cake_cmp(const cake& lhs,const cake& rhs){
    return lhs.area < rhs.area;
}

int main(){
    while(true){
        int n,w,h;
        cin >> n >> w >> h;
        if(n == 0 and w == 0 and h == 0) break;
        vector<cake> cakes;
        cakes.push_back(cake(w,h));
        for(int i=0;i<n;i++){
            int p,s;
            cin >> p >> s;
            p--;
            cake c = cakes[p];
            cakes.erase(cakes.begin()+p);
            vector<cake> ps(2,cake(0,0));
            s %= (2*(c.w+c.h));
            if(0 <= s and s <= c.w){
                ps[0] = cake(c.w-s,c.h);
                ps[1] = cake(s,c.h);
            }else if(c.w <= s and s <= c.w+c.h){
                int rest = s-c.w;
                // s <= c.w + c.h
                // rest <= c.h
                ps[0] = cake(c.w,c.h-(rest));
                ps[1] = cake(c.w,rest);
            }else if(c.w+c.h <= s and s <= c.w+c.h+c.w){
                int rest = s-(c.w+c.h);
                ps[0] = cake(rest,c.h);
                ps[1] = cake(c.w-rest,c.h);
            }else{
                int rest = s-(c.w+c.h+c.w);
                ps[0] = cake(c.w,rest);
                ps[1] = cake(c.w,c.h-rest);
            }
            if(ps[0].area > ps[1].area){
                swap(ps[0],ps[1]);
            }
            for(int i=0;i<2;i++){
                cakes.push_back(ps[i]);
            }
        }

        sort(all(cakes),cake_cmp);
        for(int i=0;i<cakes.size();i++){
            cout << cakes[i].area;
            if(i == cakes.size() -1){
                cout << endl;
            }else{
                cout << " ";
            }
        }
    }
    return 0;
}

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

typedef long long ll;
const int maxn = 3000 + 2;
ll dp[maxn][maxn];
int a[maxn];

ll solve(int l, int r) {
    if (l > r) return 0;
    if (l == r) return a[l];
    ll &res = dp[l][r];
    if (res != -1) return res;

    ll op1 = a[l] + min(solve(l+2, r), solve(l+1, r-1));
    ll op2 = a[r] + min(solve(l, r-2), solve(l+1, r-1));

    res = max(res, max(op1, op2));
    return res;
}

int main() {

    int n;
    scanf("%d", &n);
    ll sum = 0L;

    for (int &x: a) {
        scanf("%d", &x);
        sum += x;
    }

    memset(dp, -1, sizeof(dp));

    cout << (2*solve(0, n-1) - sum);
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

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

    vector<int> G(N+1, 0);
    rep(i, M) {
        int l, r;
        cin >> l >> r;
        l--;
        G[l]++;
        G[r]--;
    }

    rep(i, N) G[i+1] += G[i];
    int res = 0;
    rep(i, N) if (G[i]==M) res++;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
N,W=map(int,input().split())
list1=[list(map(int,input().split())) for i in range(N)]

dp=[[0 for i in range(W+1)] for j in range(N+1)] # dpリストを作る。dpの要素の数字は価値を表す。

for i in range(N): # １つ１つの商品について
    for w in range(W+1):
        if w>=list1[i][0]:
            dp[i+1][w]=max(dp[i][w],dp[i][w-list1[i][0]]+list1[i][1])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[-1][-1])

Measured memory_bytes: 171656
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	ll n, m, x;
	cin >> n >> m >> x;
	vector <int> C(n);
	vector <vector<ll>> A(n, vector<ll>(m));

	for (int i = 0; i < n; i++) {
		cin >> C[i];
		for (int j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}

	/*for (int i = 1; i < m; i++) {
		if (std::accumulate(A[i].begin(), A[i].end(), 0) < x) {
			cout << -1;
			return 0;
		}
	}*/

	ll ans = 1e8;
	for (int i = 0; i < 1 << n; i++) {
		ll cost = 0;
		vector<int> d(m);
		for (int j = 0; j < n; j++) {
			if (i >> j & 1) {
				cost += C[j];
				for (int k = 0; k < m; k++)
					d[k] += A[j][k];
			}
		}
		bool flag = true;

		for (int j = 0; j < m; j++) {
			if (d[j] < x) {
				flag = false;
			}
		}
		if(flag) ans = std::min(ans, cost);
	}
	if (ans == 1e8)cout << -1 << endl;
	else cout << ans;
	
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main() {
	int n, m;
	int C[21];
	int T[NMAX + 1];
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> C[i];
	}
	for (int i = 0; i <= NMAX; i++) {
		T[i] = INFTY;
	}
	T[0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = C[i]; j <= n; j++) {
			T[j] = min(T[j], T[j-C[i]] + 1);
		}
	}

	cout << T[n] << endl;
}



Measured memory_bytes: 3280