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

int sum(int x){
  int tmp=0;
  while (x>0){
    tmp+=x%10;
    x/=10;
  }
  return tmp;
}
  





int main() {
  int m;
  cin>>m;
  
  cout<<48-m<<endl;
}

  













Measured memory_bytes: 256
#include<queue>
#include<ctime>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<memory.h>
#include<map>
#include<ctime>
#include<algorithm>
#include<ctime>
#include<set>
#define ll int
#define For(i,j,k)  for(ll i=j;i<=k;++i)
#define FOr(i,j,k)  for(ll i=j;i>=k;--i)
#define rep(i,j,k)	for(ll i=j;i<k;++i)
#define ld double
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; }
inline void wrote(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) wrote(x/10);   putchar(x%10+'0');  }
inline void writeln(ll x){ wrote(x);   puts("");   }
const ll N=200010,inf=1000000;
char s[N];
ll now,f[1<<26|111],bin[100],n;
int main(){
	bin[0]=1;	For(i,1,26)	bin[i]=bin[i-1]<<1;
	scanf("%s",s+1);	n=strlen(s+1);
	For(i,0,bin[26]-1)	f[i]=inf;
	f[0]=0;
	For(i,1,n){
		now^=bin[s[i]-'a'];
		For(j,0,25)	f[now]=min(f[now],f[now^bin[j]]+1);
	}writeln(max(f[now],1));
}

Measured memory_bytes: 262656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[4];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  cout<<a[2]*10+a[0]+a[1]<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int T, X;
    std::cin >> T >> X;

    std::cout << double(T) / double(X) << std::endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef ONLINE_JUDGE
  #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif

#include "bits/stdc++.h"
using namespace std;
#define int long long

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

signed main() {
  #ifndef ONLINE_JUDGE
    ifstream cin("in");
  #endif
  ios_base::sync_with_stdio(0); cin.tie(0); // harris leung ioi gold calling it 18.09

  int n, w; cin >> n >> w;
  int a[n], b[n]; // w, v
  for (int i = 0; i < n; i ++) cin >> a[i] >> b[i];
  int f[w + 1]; memset(f, 0, sizeof(f));
  for (int i = 0; i < n; i ++) {
    for (int j = w; j >= a[i]; j --) {
      if (f[j - a[i]] + b[i] > f[j]) f[j] = f[j - a[i]] + b[i];
    }
  }
  cout << f[w] << endl;
}

Measured memory_bytes: 4368
#include<iostream>
 
using namespace std;
 
int main(){
  int a;
  int b;
  int c;
  int x;
  int y;
  int z;
  cin >> a >> b >> c;
  if (a <= b && a <= c){
    x = a;
    if(b <= c){
    y = b;
    z = c;
    }else{
    y = c;
    z = b;
    }
  }else if(b <= a && b <= c){
    x = b;
    if(a <= c){
      y = a;
      z = c;
    }else{
      y = c;
      z = a;
    }
  }else{
    x = c;
    if (a <= b){
      y = a;
      z = b;
    }else{
      y = b;
      z = a;
    }
  }
  cout << x << " " << y << " " << z << endl;
  return 0;
}


Measured memory_bytes: 3096
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$K) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
$hh = explode(" ",trim(fgets(STDIN)));
foreach($hh as $v) {
  $h[]=(int)$v;
}

$dp[0]=0;
for($i=1;$i<(int)$N;++$i) {
  $dp[$i]=PHP_INT_MAX;
  $limit = min($i,(int)$K);
  for($j=1;$j<=$limit;++$j) {
    $dp[$i]=min($dp[$i],$dp[$i-$j]+abs($h[$i]-$h[$i-$j]));
  }
}
printf("%d\n",$dp[$N-1]);


Measured memory_bytes: 23024
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 2999;
const int P = 10;

double dp[MAXN + 1][MAXN + 1];
double a[MAXN + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << setprecision(P) << fixed;
}

int main() {
	fast_io();
//	freopen("input/dp_i.txt", "r", stdin);
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	dp[0][0] = 1.0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= i; j++) {
			if(j) dp[i][j] = (dp[i - 1][j - 1] * a[i]);
			dp[i][j] += (dp[i - 1][j] * (1.0 - a[i]));
		}			
	}

	double ans = 0.0;
	for(int i = 1; i <= n; i++) {
		int t = n - i;
		if(i > t) ans += dp[n][i];
	}
	
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define ll long long int
#define r(a, b) for(ll i = a; i < b; i++)
#define pb push_back
using namespace std;
#define mod 998244353
const long long int INF = 1e10;
vector<ll>v;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    double a,b;
    cin>>a>>b;
    cout<<ceil((double)a/(double)b)<<"\n";
    return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;

const LD PI = acos(-1);

void Main(){
    ll n, l; cin >> n >> l;
    vll t(n);
    rep(i, n) cin >> t[i];
    LD ansx = 0;
    LD ansy = 0;
    rep(i, n-1){
        rep3(j, i+1, n-1){
            LD mid = LD(t[i] + t[j]) / l; 
            LD mid2 = mid + 1;
            if(mid2 >= 2) mid2 -= 2;
            ll cnt = j - i - 1;
            ll cnt2 = n - 2 - cnt;
            ansx += cos(mid * PI) * cnt2 + cos(mid2 * PI) * cnt;
            ansy += sin(mid * PI) * cnt2 + sin(mid2 * PI) * cnt;
            // cout << i << ", " << j << ": " << mid << ", " << mid2 << ": " << cnt << ", " << cnt2 << ": " << ansx << ", " << ansy << endl;
        }
    }
    ll tot = n * (n-1) * (n-2) / 6;
    cout << ansx/tot << " " << ansy/tot << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 4196
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input!(_x: i64, k: u64, d: u64);

    let x: u64 = _x.abs() as u64;
    if (x + d - 1) / d > k {
        println!("{}", x - k * d);
    }
    else {
        let j = x / d;
        let x2 = x - d * j;

        if (k - j) % 2 == 0 {
            println!("{}", x2);
        }
        else {
            println!("{}", d - x2);
        }
    }
}


Measured memory_bytes: 2180
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 60
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[MAXN][MAXN*2],c[MAXN][MAXN]; 
int n;
int main(){
	SF("%d",&n);
	for(int i=0;i<MAXN;i++)
		for(int j=0;j<=i;j++){
			if(j==0)
				c[i][j]=1;
			else
				c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
		}
	dp[1][MAXN]=1;
	dp[1][MAXN-1]=1;
	for(int i=1;i<50;i++)
		for(int j=-i;j<=i;j++){
			for(int sum=max(abs(j),1);sum<=50;sum++){
				if(i+sum>50||(sum+j)%2)
					continue;
				for(int pos=0;pos<=sum;pos++){
					int t=sum-pos;
					int val=(j+pos-t)/2;
					if(val<-50||val>50)
						continue;
					dp[i+sum][val+MAXN]+=dp[i][j+MAXN]*c[i+sum][sum]%MOD*c[sum][pos]%MOD;
					dp[i+sum][val+MAXN]%=MOD;
				}
			}
		}
	PF("%lld\n",dp[n][MAXN]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <utility>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<pair<int, int>> vp;

    for (int i = 1; i < N;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        vp.push_back(make_pair(a, b));
    }

    int K = 0;
    map<pair<int, int>, int> I;
    vector<int> cs(N, 0);

    vector<int> used(N, 0);
    queue<int> q;
    used[0] = 1;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        if((int)G[v].size() > K)
            K = G[v].size();
        int cur = 1;
        for(int u:G[v]){
            if(used[u])
                continue;
            if(cur == cs[v])
                cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u] = 1;
            q.push(u);
        }
    }
    cout << K << endl;
    for (auto p:vp)
        cout << I[p] << endl;
    return 0;
}

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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

void solve(){
	int n;
	cin>>n;
	vector<int> v(n);	
	long long ans=0;
	for(int &i:v){
		cin>>i;
		ans += i;
      	ans %= mod;
	}	
	long resp = 0;
	for(size_t i:v){
		ans -= i;      
		if(ans < 0) ans += mod;          
		resp += (i * ans);
        resp %= mod;
	}	
	cout<<resp<<endl;
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}


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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
template<class T> inline bool is_overlap(const T& as, const T& ae, const T& bs, const T& be)
{ return bs <=ae && as <= be; }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

template<class T> void sort3d(T& a,T& b,T& c) {if (a<b) swap(a,b); if (b<c) swap(b,c); if (a<b) swap(a,b);}

#define PI 3.141592653589793

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> W(N); cin >> W;
    vector<int> acc_l(N), acc_r(N);

    rep(i, N) {
        if (i == 0) {
            acc_l[0] = W[0];
            acc_r[N-1] = W[N-1];
        } else {
            acc_l[i] = acc_l[i-1]+W[i];
            acc_r[N-1-i] = W[N-1-i]+acc_r[N-i];
        }
    }

    int d = INT_MAX;

    for (int i = 0; i < N - 1; i++)
        chmin(d, abs(acc_l[i] - acc_r[i+1]));
    
    cout << d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
map<int, int> mp;

int main(void){
    
    scanf("%d", &N);
    int ans = 0;
    for(int i = 0; i < N; ++i){
        int d; scanf("%d", &d);
        if(mp.find(d) == mp.end()) ++ans, ++mp[d];
    }
    printf("%d\n", ans);
	
    return 0;
}


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

const int MOD = 1e9+7;
int n, a, cnt[100005];
long long ans;

long long binexp(long long x, long long y) {
    long long res = 1;
    x %= MOD;
    while (y) {
        if (y&1) {
        	res = (res * x) % MOD;
        }
        y >>= 1;
        x = (x * x) % MOD;
    }
    return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cnt[a]++;
	}

	int odd = 0;
	for (int i = 0; i < n; i++) {
		if (cnt[i] != 0 && cnt[i] != 2 && !(n&1)) {
			cout << 0 << '\n';
			return 0;
		}
		else if (i && (cnt[i]&1) && (n&1)) {
			cout << 0 << '\n';
			return 0;
		}
	}

	if ((n&1) && !(cnt[0]&1)) {
		cout << 0 << '\n';
		return 0;
	}

	cout << binexp(2, n/2) << '\n';
 
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#pragma warning(disable:4996)
int main()
{
	char a[51], b[51];
	scanf("%s", a);
	scanf("%s", b);
	int u = 0;
	for (int i = 0; i < strlen(a); i++)
	{
		int count = 0;
		for (int j = 0; j < strlen(b); j++)
		{
			if (a[i + j] == b[j] || a[i + j] == '?')
			{
				count++;
			}
		}
		if (count == strlen(b))
		{
			u = i+1;
		}
	}
	if (u==0)
	{
		printf("UNRESTORABLE");
	}
	else
	{
		for (int i = 0; i < u-1; i++)
		{
			if (a[i]=='?')
			{
				a[i] = 'a';
			}
		}
		for (int i = u-1; i < u-1+strlen(b); i++)
		{
			a[i] = b[i + 1 - u];
		}
		for (int i = u - 1 + strlen(b); i < strlen(a); i++)
		{
			if (a[i] == '?')
			{
				a[i] = 'a';
			}
		}
		printf("%s", a);
	}
	return 0;

}

Measured memory_bytes: 128
public class Main {


  private static void solve() {
    double n = ni();
    double m = ni();
    double d = ni();
    
    double x = d == 0 ? 1 / n : 2 * (n - d) / n / n;
    System.out.printf("%.12f\n", x * (m - 1));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main(){
    int a,b;cin>>a>>b;
    if(a>=b){
        int cnt=0;
        while(cnt<a){
            cout<<b;
            cnt++;
        }
        cout<<endl;
    }
    else{
        int cnt=0;
        while(cnt<b){
            cout<<a;
            cnt++;
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18

using namespace std;






int main(){
	int n, a, b;
	cin >> n >> a >> b;
	
	while(1){
		if(a+1<b && a+1<=n) a+=1;
		else if(a-1>=0) a-=1;
		else { cout<<"Borys"<<endl; return 0; }
		
		if(b-1>a && b-1>=0) b-=1;
		else if(b<=n) b+=1;
		else { cout<<"Alice"<<endl; return 0; }
	}
	
	return 0;
}




Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_variables)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::mem::swap;
use std::io::prelude::*; // input()

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize1; n],
        b: [usize; n],
        c: [usize; n-1],
    }
    let mut cnt = 0;
    let mut pre = 200;
    for i in a {
        cnt += b[i];
        if pre + 1 == i {
            cnt += c[pre];
        }
        pre = i;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
stu = []
che = []
for i in range(N):
    A = list(map(int, input().split()))
    stu.append(A)
for i in range(M):
    B = list(map(int, input().split()))
    che.append(B)
for i in range(N):
    poi = []
    for j in range(M):
        poi.append(abs(stu[i][0]-che[j][0])+abs(stu[i][1]-che[j][1]))
    print(poi.index(min(poi))+1)
        

Measured memory_bytes: 39408
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int h, w;
    cin >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << '\n';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    string S; cin >> S;
    vector<int> v(4,0);
    for(int i=0;i<S.size();i++){
        if(S[i] =='N') v[0]++;
        if(S[i] =='W') v[1]++;
        if(S[i] =='S') v[2]++;
        if(S[i] =='E') v[3]++;
    }
    int count =0;
    for(int i=0;i<4;i++) {if(v[i] == 0) count++;}
    if(count == 1 || count == 3) cout << "No" << endl;
    else if(v[0]*v[2] == 0 && v[1]*v[3] == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}




Measured memory_bytes: 256
h = w = 0
slist =[]
list1=[]
def dfs(f):
    while True:
        if len(slist) == 0:
            return 1
        coordinate= slist.pop()
        #print(coordinate)
        x = coordinate[0]
        y = coordinate[1]

        list1[y] = list1[y][:x] + '1' + list1[y][x + 1:]
        if x + 1 < w:
            if list1[y][x + 1] == f:
                slist.append([x + 1,y])
        if x - 1 >= 0:
            if list1[y][x-1] == f:
                slist.append([x - 1, y])
        if y + 1 < h:
            if list1[y + 1][x] == f:
                slist.append([x, y + 1])
        if y -1 >= 0:
            if list1[y -1][x] == f:
                slist.append([x, y - 1])

while True:
    h, w = list(map(lambda x: int(x),input().split(" ")))
    if 0 in (h, w):
        break
    n = 0
    for i in range(0, h):
        list1.append(input())
    for i in range(0, h):
        for j in range(0, w):
            if list1[i][j] != '1':
                slist.append([j,i])
                n += dfs(list1[i][j])
            #print(list1)
    print(n)
    list1=[]

Measured memory_bytes: 8652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

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

  ll N,M,x,y,redpos = 1; cin >> N >> M;
  vector<ll> bvec(N,1);
  vector<ll> redbool(N,0); redbool[0] = 1;
  for (ll i = 0; i < M; ++i) {
    cin >> x >> y;
    bvec[x-1] -=1; bvec[y-1] += 1;
    if (redbool[x-1] == 1) redbool[y-1] = 1;
    if (bvec[x-1] == 0) redbool[x-1] = 0;
  }
  cout << accumulate(redbool.begin(), redbool.end(),0) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  ll n, m;
  scanf("%lld %lld", &n, &m);

  map<ll, ll> r;
  for (ll i = 1; i <= n; i++) {
    r[i] = 0;
  }

  ll anum = 0;
  ll pnum = 0;

  for (ll i = 0; i < m; i++) {
    ll id;
    string s;
    cin >> id;
    cin >> s;

    if (r[id] == -1) {
      continue;
    }

    if (s == "WA") {
      r[id]++;
    } else if (s == "AC") {
      anum++;
      pnum += r[id];
      r[id] = -1;
    }
  }

  cout << anum << " " << pnum << endl;
}

// 2 5
// 1 WA
// 1 AC
// 2 WA
// 2 AC
// 2 WA


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N,K;
    cin >> N >> K;
    vector<int>a(N);
    REP(i,N){
        cin >> a[i];
        --a[i];
    }
    int LOG = 62;
    vector<vector<int>>dp(LOG,vector<int>(N,-1));
    REP(i,N)dp[0][i] = a[i];
    REP(i,LOG - 1){
        REP(j,N){
            if(dp[i][j] == -1)dp[i + 1][j] = -1;
            else dp[i + 1][j] = dp[i][dp[i][j]];
        }
    }
    int ans = 0;
    REP(i,LOG){
        if(K & (1ll << i))ans = dp[i][ans];
    }
    out(ans + 1);
}

Measured memory_bytes: 103264
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main(void){
    int H,W;
    
    while(1){
        scanf("%d %d",&H,&W);
        
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(i == 0 || i == H-1 || j == 0 || j == W-1)
                    printf("#");
                else
                    printf(".");
            }
            printf("\n");
        }
        if(H == 0 && W == 0)
            break;
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 3104
#include<iostream>
using namespace std;
int main(){
	int cat,dog,x,all;
	
	cin >> cat;
	cin >> dog;
	cin >> x;
	
	all = cat+dog;
	
	if(all<x){
		cout <<"NO"<<endl;
		}
		else if(cat>x){
			cout <<"NO"<<endl;
			}
			else {
				cout << "YES"<< endl;}
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
        char c;
        cin >> c;
        if (c == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

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

constexpr int INF = 1e9;

int main() {
    int V, E;
    cin >> V >> E;
    vector<vector<int>> g(V, vector<int>(V, INF));
    for(int i=0; i<E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s][t] = d;
    }
    vector<vector<int>> dp(V, vector<int>(1 << V, INF));
    dp[0][0] = 0;
    for(int i=0; i<1<<V; ++i) {
        for(int j=0; j<V; ++j) {
            if(i >> j & 1) {
                continue;
            }
            for(int k=0; k<V; ++k) {
                dp[j][i | (1 << j)] = min(dp[j][i | (1 << j)], dp[k][i] + g[k][j]);
            }
        }
    }
    if(dp[0][(1 << V) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[0][(1 << V) - 1] << endl;
    }
}


Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i)
        cin >> L[i];

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int k = j + 1; k < N; ++k) {
                if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i])
                    continue;
                vector<int> tmp(3);
                tmp[0] = L[i], tmp[1] = L[j], tmp[2] = L[k];
                sort(tmp.begin(), tmp.end());
                if (tmp[0] + tmp[1] > tmp[2])
                    ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int d,n; 
bool f[10005];
int a[5005][5005];
inline bool check() {
	for(int i=1;i<=n;++i) if(a[i][0]!=n) return false;
	return true;
}
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int main() {
	cin>>n;
	for(int i=1;i<=n;++i) 
		for(int j=1;j<n;++j) a[i][j]=read();
	for(int i=1;i<=n;i++) a[i][0]=1;
	while(1) {
        if (check()) {printf("%d",d);return 0;}
        for(int i=1;i<=n;i++) f[i]=0;
        d++;
        bool tf=false;
        for(int i=1;i<=n;++i) {
            if(f[i]||a[i][0]==n) continue;
            int x=a[i][a[i][0]];
            int y=a[x][a[x][0]];
            if(!f[i]&&!f[x]&&y==i) {
                tf=true;
                a[i][0]++;
                a[x][0]++;
                f[i]=true;
                f[x]=true;
            }
        }
        if(!tf) {
            cout<<"-1"<<endl;
            return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 19456
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        int max = 0;
        for (int i = 1; i < N - 1; i++)
        {
            var A = new List<char>();
            var B = new List<char>();
            for (int j = 0; j < N; j++)
            {
                if (j > i)
                {
                    if (!A.Contains(S[j]))
                    {
                        A.Add(S[j]);
                    }
                }
                else
                {
                    if (!B.Contains(S[j]))
                    {
                        B.Add(S[j]);
                    }
                }
            }
            max = Math.Max(max, A.Intersect(B).Count());
        }
        Console.WriteLine(max);
    }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... 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 V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

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

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

    ll L = lcm(N,M);
    ll l = lcm(L/N,L/M);

    for(ll i = 0;i < L;i += l){
        if(s[i / (L/N)] != t[i / (L/M)]) {
            pl(-1)
            return 0;
        }
    }

    pl(L)

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

const int inf = 1e9;

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

	vector<int> units = {1};
	int tmp = 6;
	while (tmp <= n) {
		units.push_back(tmp);
		tmp *= 6;
	}
	tmp = 9;
	while (tmp <= n) {
		units.push_back(tmp);
		tmp *= 9;
	}

	vector<int> dp(n + 1, inf);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (auto x: units) {
			int to = i + x;
			if (to <= n) {
				dp[to] = min(dp[to], dp[i] + 1);
			}
		}
	}

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


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

#define rep(i,n) for(int i=0; i<n; i++)

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

  while (a>0 && b>0){
    c -= b;
    a -= d;
  }

  if(c<=0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> A;

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N) cin>>A[i];
  
  ll ans=0;
  while(1){
      vector<ll> num(N,0);
      ll sum=0;
      for(int i=0;i<N;i++){
          num[i]+=A[i]/N;
          sum+=num[i];
      }
      if(sum==0) break;

      ans+=sum;
      for(int i=0;i<N;i++){
          A[i]%=N;
          A[i]+=(sum-num[i]);
      }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n,d;
    cin>>n>>d;
    d=(2*d)+1;
    n=(n+d-1)/d;
    cout<<n;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
a = list(accumulate(a))
b = list(accumulate(b))
ans = 0
for i in range(n+1):
    if a[i] > k:
        break
    ans = max(ans, i+bisect(b, k-a[i])-1)
print(ans)

Measured memory_bytes: 41784
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
// #include <set>
// #include <cmath>
// #include <string>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}


int main(int argc, char const *argv[]) {
    int r, g, b;
    cin >> r >> g >> b;
    if ((g*10 + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(2e5)+5;




int peil(int a,int b)
{
    if(a%b)return a/b+1;
    return a/b;
}

int main()
{
    idfc;
    int n;
    ll h;
    cin>>n>>h;
    int i;
    int a=0;
    int b;
    int e;
    vector<int> vv;
    for(i=1;i<=n;i++)
    {
        cin>>e>>b;
        a=max(e,a);
        vv.pb(b);
    }
    sort(vv.begin(),vv.end(),greater<>());
    int ans=peil(h,a);

    ll s=0;
    ll d;
    for(i=1;i<=n;i++)
    {
        s+=vv[i-1];
        d=max(0ll,h-s);
        e=peil(d,a);
        ans=min(ans,e+i);
    }
    cout<<ans;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e3 + 5);

/////////////////////////////////////////////////////////////
class StringMatching {
 public:
  string s;
  string t;
  string phi;
  string sct;
  vector<int> z;

  StringMatching(string s, string t, char phi) {
    this->z = vector<int>(t.size() + 1 + s.size(), 0);

    this->s = s;
    this->t = t;
    this->phi = phi;
    init();
  }

  void init() {
    sct = t + phi + s;
    make_z();
  }

  void make_z() {
    int n = sct.size();
    int l = 0, r = 0;

    z[0] = sct.size();

    for (int i = 1; i < n; ++i) {
      if (i > r) {
        l = r = i;
        while (r < n && sct[r - l] == sct[r]) r += 1;

        z[i] = r - l;
        r -= 1;
      } else {
        int k = i - l;  // focus at prefix-substring (begin with sct[k]) with which already dealed

        // no prefix-substring (begin with sct[i]) longer than (r - i + 1) could be expected
        // since, "sct[0..(r - l)] == sct[l..r]" entails "sct[k..(r - l)] == sct[i..r]",
        // but z[k] is smaller than length of sct[i..r]
        if (z[k] < r - i + 1) {
          z[i] = z[k];
        } else {  // there could be longer prefix-substring (begin with sct[i])
          l = i;
          while (r < n && sct[r - l] == sct[r]) r += 1;

          z[i] = r - l;
          r -= 1;
        }
      }
    }
  }

  bool match_from(int i) {
    return z[t.size() + 1 + i] == t.size();
  }
};
/////////////////////////////////////////////////////////////

int n;
string s;

int check(int begin) {
  string target = s.substr(begin, s.size() - begin);

  // printf("%d\n", begin);
  // cout << target << endl;

  int min_inds[MAX_N];
  int max_inds[MAX_N];

  for (int i = 0; i <= s.size(); ++i) {
    min_inds[i] = s.size();
    max_inds[i] = -1;
  }

  StringMatching sm(s, target, '_');

  // printf("----------------\n");
  for (int i = 0; i < s.size(); ++i) {
    int cur = sm.z[sm.t.size() + 1 + i];
    // printf("(%c)%d: %d\n", s[i], cur, i);
    min_inds[cur] = min(min_inds[cur], i);
    max_inds[cur] = max(max_inds[cur], i);
  }
  // printf("----------------\n");

  int ind_min = s.size();
  int ind_max = -1;
  for (int i = s.size(); i > 0; --i) {
    ind_min = min(ind_min, min_inds[i]);
    ind_max = max(ind_max, max_inds[i]);

    min_inds[i] = ind_min;
    max_inds[i] = ind_max;
  }

  int ret = 0;

  for (int i = 1; i < s.size(); ++i) {
    if (min_inds[i] == max_inds[i]) continue;

    // printf("begin: %d, len: %d\n", begin, i);

    if (min_inds[i] + i - 1 < max_inds[i]) {
      // printf("begin: %d, len: %d\n", begin, i);
      ret = max(ret, i);
    }
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  cin >> s;

  int ans = 0;

  for (int i = 0; i < s.size(); ++i) {
    ans = max(ans, check(i));
  }

  printf("%d\n", ans);

  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int check = 0;
    for (int i =0; i <s.size(); ++i) {
        for (int j =0; j <i; ++j) {
            if (s[i] == s[j]) {
                check += 1;
            }
        }
    }
    if (check == 0) {
        cout << "yes"<< endl;
    }else{
        cout << "no" << endl;
    }

    return 0;
}

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

int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(x<r){
    cout << "No" << endl;
  }
  else if(y<r){
    cout << "No" << endl;
  }
  else if(W-x<r){
    cout << "No" << endl;
  }
  else if(H-y<r){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(){
	int n;
	string A,B,C;
	cin>>n;
	int count=0;
	cin>>A>>B>>C;
	for(int i=0;i<n;i++){
		if(A[i]==B[i]){
			if(B[i]!=C[i])
			count++;
		}
		else if(B[i]==C[i]){
			count++;
		}
		else if(A[i]==C[i]){
			count++;
		}
		else{
			count+=2;
		}
	}
	cout<<count;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    static int n;
    static int[] array;
    static Deque<Integer> deque;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        array = new int[n];
        deque = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (i%2 == 0) {
                deque.addFirst(array[i]);
            } else {
                deque.addLast(array[i]);
            }
        }
        if (n % 2 == 0) {
            for (int i = 0; i < n; i++) {
                System.out.print(deque.pollLast());
                if (i != n-1) System.out.print(" ");
            }
        } else {
            for (int i = 0; i < n; i++) {
                System.out.print(deque.pollFirst());
                if (i != n-1) System.out.print(" ");
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 93320
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> t(n + 1), x(n + 1), y(n + 1);
        t[0] = x[0] = y[0] = 0;
        for (int i = 1; i <= n; i ++) {
                scanf("%d%d%d", &t[i], &x[i], &y[i]);
        }
        for (int i = 1; i <= n; i ++) {
                int d = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
                if (d % 2 != (t[i] - t[i - 1]) % 2 || d > t[i] - t[i - 1]) {
                        return !printf("No\n");
                }
        }
        return !printf("Yes\n");
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

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

int n;

int main(void){
  ios_base::sync_with_stdio(0);
  while(cin >> n, n){
    vector<ull> vec(n, 0);
    for(int i = 0; i < n; i++) cin >> vec[i];
    sort(vec.begin(), vec.end());

    ull sum = 0, ans = 0;
    for(int i = 0; i < n; i++){
      ans += sum;
      sum += vec[i];
    }
    cout << ans << endl;
  }
  return 0; 
}

Measured memory_bytes: 1304
#include<stdio.h>
int main()
{
	int n,k,i,f,z[50],x;
	
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&z[i]);
	}
	do{f=0;
		for(i=0;i<n-1;i++){
			if(z[i]<z[i+1]){
				z[i]^=z[i+1];
				z[i+1]^=z[i];
				z[i]^=z[i+1];
				f=1;
			}
		}
	}while(f==1);
	
	for(i=0;i<k;i++)x+=z[i];
	printf("%d\n",x);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
const int maxn = 3e6; 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll a, b;
	cin >> a >> b;
	ll g = __gcd(a, b);
	ll answer = 0;
	ll g2 = g;
	debug(g);
	for (ll i = 2;i * i <= g;++i) {
		if (g % i == 0) {
			debug(i);
			++answer;
			while (g % i == 0) {
				g /= i;
			}
		}
	}
	if (g != 1) {
		++answer;
	}
	cout << answer + 1 << '\n';
	return 0;
}


Measured memory_bytes: 256