akhauriyash/Code-Regression huggingface dataset:
# Solution reference: https://qiita.com/drken/items/e805e3f514acceb87602#%E6%9C%80%E5%A4%A7%E4%BA%8C%E9%83%A8%E3%83%9E%E3%83%83%E3%83%81%E3%83%B3%E3%82%B0%E5%95%8F%E9%A1%8C%E3%82%92%E6%9C%80%E5%A4%A7%E6%B5%81%E5%95%8F%E9%A1%8C%E3%81%AB%E5%B8%B0%E7%9D%80%E3%81%99%E3%82%8B
# Dinic reference: https://atcoder.jp/contests/abc091/submissions/5569121
class Dinic
  attr_accessor :g
  def initialize(v, inf = 2 ** 30)
    @V = v
    @inf = inf
    @g = Array.new(v) { [] }
    @level = Array.new(v, 0)
    @iter = Array.new(v, 0)
  end

  def add_edge(from, to, cap)
    @g[from] << {to: to, cap: cap, rev: @g[to].size}
    @g[to] << {to: from, cap: 0, rev: @g[from].size - 1}
  end

  def max_flow(s, t)
    flow = 0
    loop do
      bfs(s)
      return flow if @level[t] < 0
      @iter = Array.new(@V, 0)
      f = dfs(s, t, @inf)
      while f > 0
        flow += f
        f = dfs(s, t, @inf)
      end
    end
  end

  private
    def bfs(s)
      @level = Array.new(@V, -1)
      @level[s] = 0
      q = [s]
      until q.empty?
        v = q.shift
        @g[v].size.times do |i|
          e = @g[v][i]
          if e[:cap] > 0 && @level[e[:to]] < 0
            @level[e[:to]] = @level[v] + 1
            q << e[:to]
          end
        end
      end
    end

    def dfs(v, t, f)
      return f if v == t
      (@iter[v]...@g[v].size).each do |i|
        @iter[v] = i
        e = @g[v][i]
        if e[:cap] > 0 && @level[v] < @level[e[:to]]
          d = dfs(e[:to], t, [f, e[:cap]].min)
          if d > 0
            e[:cap] -= d
            @g[e[:to]][e[:rev]][:cap] += d
            return d
          end
        end
      end
      0
    end
end

n = gets.to_i
reds = []
blues = []
n.times { reds << gets.split.map(&:to_i) }
n.times { blues << gets.split.map(&:to_i) }
dinic = Dinic.new(2 * n + 2)
s = 2 * n
t = s + 1

n.times do |i|
  dinic.add_edge(s, i, 1)
  dinic.add_edge(i + n, t, 1)
end

blues.each_with_index do |(blue_x, blue_y), blue_i|
  reds.each_with_index do |(red_x, red_y), red_i|
    if red_x < blue_x && red_y < blue_y
      dinic.add_edge(blue_i, red_i + n, 1)
    end
  end
end

puts dinic.max_flow(s, t)


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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

const string YES = "Yes";
const string NO = "No";

void func(long long K, long long X){
    cout << (K*500>=X? YES: NO) << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    func(K, X);
    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, h, w;
int a, b, ans;

int main(){
    cin >> n >> h >> w;
    REP(i, n){
        cin >> a >> b;
        if(h <= a && w <= b)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = 1e5 + 5;
typedef long long ll;
int n,p;
ll c[maxn];
int main(){
//    freopen("e:\\in.txt","r",stdin);
    cin>>n>>p;
    ll w,b,need = 0;
    for(int i = 0; i < n; i++){
        cin>>w>>b;
        need += b;
        c[i] = (100 - p) * w + p * b;
    }
    sort(c, c + n);
    ll cnt = 0;
    need *= p;
    for(int i = n - 1; i >=0; i--){
        cnt++;
        need -= c[i];
        if(need <=0)break;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1024
//abc164-D//
//#include <math.h>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<stdio.h>
#include <iostream>
#include <vector>
//#include <string.h>
using namespace std;

int main(){
    int pages;
    cin >> pages;
    int ans = pages/2 + pages%2;
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int w, h, map[51][51], diff[9]={-1, 0, 1, 0, -1, 1, 1, -1, -1};

bool check(int j, int k){
	return (j>=0 && j<h && k>=0 && k<w && map[j][k]>0);
}

void dfs(int j, int k){
	REP(i,8){
		if (check(j+diff[i], k+diff[i+1])){
			map[j+diff[i]][k+diff[i+1]] = 0;
			dfs(j+diff[i],k+diff[i+1]);
		}
	}
	return;
}

int main(){
	while(1){
		int ans=0;
		cin >> w >> h;
		if (w==0 && h==0) break;
		REP(j,h){
			REP(k,w) map[j][k] = 0;
		}
		REP(j,h){
			REP(k,w) cin >> map[j][k];
		}
		REP(j,h){
			REP(k,w){
				if (check(j,k)){
					ans++;
					dfs(j,k);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3148
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))


R, C, N = rli()
lis = []
idx = 0
i = 0
for j in range(N):
    x1, y1, x2, y2 = rli()
    if((x1 % R == 0 or y1 % C == 0) and (x2 % R == 0 or y2 % C == 0)):
        i += 1
        for _ in range(2):
            if(y1 == 0):
                lis.append([x1, i])
            elif(x1 == R):
                lis.append([R+y1, i])
            elif(y1 == C):
                lis.append([2*R+C-x1, i])
            elif(x1 == 0):
                lis.append([2*R+2*C-y1, i])
            x1 = x2
            y1 = y2
lis.sort()
stack = []
exist = [False for _ in range(2*i)]
ans = True
for k in range(2*i):
    if(exist[lis[k][1]]):
        if(lis[k][1] != stack.pop()):
            ans = False
            break
        exist[lis[k][1]] = False
    else:
        stack.append(lis[k][1])
        exist[lis[k][1]] = True
if(ans):
    print("YES")
else:
    print("NO")


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


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

  int a[4][13];//s,h,c,d
  char ss[4]={'S','H','C','D'};
  char c;
  int ci;

  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 13; j++)
      a[i][j] = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> c;
    cin >> ci;
    ci--;
    switch (c)
    {
    case 'S':
      a[0][ci] = 1;
      break;
    case 'H':
      a[1][ci] = 1;
      break;
    case 'C':
      a[2][ci] = 1;
      break;
    case 'D':
      a[3][ci] = 1;
      break;
    }
  }

  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 13; j++) {
      if (a[i][j]==0) {
        cout << ss[i] << " " << (j+1)<<endl;
      }
    };

  return 0;
}



Measured memory_bytes: 3092
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

struct point{
	int ptx,pty,pkx,pky,cnt;
	point(int ptx,int pty,int pkx,int pky,int cnt):ptx(ptx),pty(pty),pkx(pkx),pky(pky),cnt(cnt){}
};

int X,Y;
int tx,ty;
int kx,ky;
int board[55][55];
bool memo[55][55][55][55];
int main(){
	while(cin>>X>>Y,X||Y){
		queue<point> que;
		while(!que.empty()){
			que.pop();
		}
		memset(memo,false,sizeof(memo));
		cin>>tx>>ty>>kx>>ky;
		for(int i = 1;i <=Y;i++){
			for(int j = 1;j <=X;j++){
				cin>>board[i][j];
			}
		}
		que.push(point(tx,ty,kx,ky,0));
		int ans = 200;
		while(!que.empty()){
			point p = que.front();
			que.pop();
			if(p.cnt>=100){
				break;
			}
			if(p.ptx==p.pkx&&p.pty==p.pky){
				ans =min(ans,p.cnt);
				break;
			}if(memo[p.ptx][p.pty][p.pkx][p.pky])
				continue;
			memo[p.ptx][p.pty][p.pkx][p.pky]=true;
			for(int i = 0;i < 4;i++){
				int ntx = p.ptx + dx[i];
				int nty = p.pty + dy[i];
				int nkx  =p.pkx + dx[(i+2)%4];
				int nky = p.pky + dy[(i+2)%4];
				if(ntx >X||ntx <=0||nty>Y||nty <=0||board[nty][ntx]==1){
					ntx =p.ptx;
					nty =p.pty;
				}
				if(nkx >X||nkx<=0||nky>Y||nky<=0||board[nky][nkx]==1){
					nkx = p.pkx;
					nky = p.pky;
				}
				que.push(point(ntx,nty,nkx,nky,p.cnt+1));
			}
		}
		if(ans>=100){
			cout <<"NA"<<endl;
		}else{
			cout <<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11348
N, X = list(map(int, input().split()))

a = [1]
p = [1]

for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def dp(N, X):
    if N == 0:
        return 1
    else:
        if X == 1:
            return 0
        elif X <= 1 + a[N-1]:
            return dp(N-1,X-1)
        elif X == 1 + a[N-1] + 1:
            return p[N-1] + 1
        elif X <= 1 + a[N-1] + 1 + a[N-1]:
            return p[N-1] + 1 + dp(N-1,X-1-a[N-1]-1)
        else:
            return p[N]

print(dp(N, X))

Measured memory_bytes: 3188
//
// Created by 吉川純平 on 2019-12-01.
//

#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//using ull = unsigned long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
struct Node{
    ll parent = -1;
    ll left = -1;
    ll right = -1;
    ll sibling = -1;
    ll depth = -1;
    ll degree = 1;
    ll height = 0;
    ll kinds = 1;
};
struct Node node[30];
void dfs(ll num,ll depth){
  if(num == -1){return;}
  node[num].depth = depth;
  dfs(node[num].left,depth+1);
  dfs(node[num].right,depth+1);
}
void calcheight(ll num,ll height){
  if(num == -1){return;}
  chmax(node[num].height,height);
  calcheight(node[num].parent,height+1);
}
int main(){
  ll n;
  cin >> n;
  ll num,l,r;
  rep(i,n){
    cin >> num >> l >> r;
    node[num].left = l;
    node[num].right = r;
    node[l].parent = num;
    node[r].parent = num;
    if(l != -1 && r != -1){
      node[num].degree = 2;
      node[l].sibling = r;
      node[r].sibling = l;
    }
    if(l == -1 && r == -1){
      node[num].degree = 0;
      node[num].kinds = 2;
    }
  }
  ll root;
  rep(i,n){
    if(node[i].parent == -1){
      root = i;
      break;
    }
  }
  node[root].kinds = 0;
  dfs(root,0);
  rep(i,n){
    calcheight(i,0);
  }
  rep(i,n){
//    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n"
//            ,i,node[i].parent,node[i].sibling,node[i].degree,node[i].depth,node[i].height,node[i].kinds.c_str());
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
            ,i,node[i].parent,node[i].sibling,node[i].degree,node[i].depth,node[i].height);
    if(node[i].kinds == 0){
      printf(" root\n");
    }else if(node[i].kinds == 2){
      printf(" leaf\n");
    }else{
      printf(" internal node\n");
    }
  }
  return 0;
}




Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string s;
	cin >> s;
	
	int n;
	static ll a[500010] = {};
	n = s.size();
	rep(i,n)a[i] = (ll)(s[n-1-i]-'0');
	
	rep(i,n){
		a[i] *= 9;
	}
	rep(i,n){
		if(a[i] >= 10){
			a[i+1] += a[i]/10;
			a[i] %= 10;
		}
	}
	
	//rrep(i,n+1)cout << a[i];
	//cout << endl;
	
	ll cnt = 0;
	rep(i,n+1)if(a[i] == 9)cnt ++;
	ll ret = 0;
	for(int i = n ; i >= 10 ; i --){
		ret += a[i];
		if(a[0] == 9)cnt --;
		a[0] += a[i];
		if(a[0] == 9)cnt ++;
		if(a[i] == 9)cnt --;
		a[i] = 0;
		rep(j,n){
			if(a[j] >= 10){
				if(a[j+1] == 9)cnt --;
				a[j+1] += a[j]/10;
				if(a[j+1] == 9)cnt ++;
				a[j] %= 10;
				if(a[j] == 9)cnt ++;
			}
			else break;
		}
		if(cnt == i){
			ret ++;
			cout << (ret+8)/9 << endl;
			return 0;
		}
	}
	
	//rrep(i,n+1)cout << a[i];
	//cout << endl;
	
	ll N = 0;
	ll t = 1;
	rep(i,10){
		N += a[i]*t;
		t *= 10;
	}
	N /= 9;
	//cout << N << endl;
	
	ll x[10];
	x[0] = 1;
	rep1(i,9)x[i] = x[i-1]*10+1;
	
	rrep(i,10){
		//cout << i << " " << x[i] << endl;
		//cout << i << " " << N/x[i] << endl;
		ret += N/x[i];
		N %= x[i];
		//cout << N << endl;
	}
	
	//cout << ret << endl;
	cout << (ret+8)/9 << endl;
}
	



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

using namespace std;

int N;
char sir[200009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s", sir + 1), N = strlen (sir + 1);
long long ans = 0;
int cntB = 0;
for (int i=1; i<=N; i++)
{
    cntB += (sir[i] == 'B');
    if (sir[i] == 'W') ans += cntB;
}
printf ("%lld\n", ans);

return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  double a,b,c,d,e,f;
  while( cin >> a >> b >> c >> d >> e >> f ){
    double y = (a*f - c*d) / (a*e - b*d);
    double x = (c - b*y) / a;
    if(x == -0) x = 0;
    if(y == -0) y = 0;
    printf("%.3lf %.3lf\n", x, y);
  }

  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val s = sc.nextLine()
    val t = sc.nextLine()
    var ans = 2 * n
    for (k in 1..n) {
        if (s.substring(n - k) == t.substring(0, k)) {
            ans = 2 * n - k
        }
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 29352
fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    println!("{}", (n - 1) * n / 2);
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string str;
bool fun(int* fp,int x)
{
    int i;bool flg=0;
    for(i=2;i<x;i++)
    {
        if(str[i-1]=='x'&&fp[i-1]==1)fp[i]=!fp[i-2];
        else if(str[i-1]=='x'&&fp[i-1]==0)fp[i]=fp[i-2];
        
        if(str[i-1]=='o'&&fp[i-1]==1)fp[i]=fp[i-2];
        else if(str[i-1]=='o'&&fp[i-1]==0)fp[i]=!fp[i-2];
    }
    if(str[x-1]=='x')
    {
        if(fp[0]==fp[x-2]&&fp[x-1]==1)flg=1;
        if(fp[0]!=fp[x-2]&&fp[x-1]==0)flg=1;
    }
    else{
        if(fp[0]!=fp[x-2]&&fp[x-1]==1)flg=1;
        if(fp[0]==fp[x-2]&&fp[x-1]==0)flg=1;
    }
    
    if(str[0]=='x')
    {
        if(fp[x-1]==fp[1]&&fp[0]==1)flg=1;
        if(fp[x-1]!=fp[1]&&fp[0]==0)flg=1;
    }
    else{
        if(fp[1]!=fp[x-1]&&fp[0]==1)flg=1;
        if(fp[x-1]==fp[1]&&fp[0]==0)flg=1;
    }
    return flg;
}

void print(int *fp,int x)
{
    for(int i=0;i<x;i++)
    {
        if(fp[i]==1)cout<<"S";
        else cout<<"W";
    }
}
int main()
{
    int n;
    
    int fp[100000];
    cin>>n;
    cin>>str;
    int i;
    int x= str.length();
    int cnt1=0,cnt2=0;
    
    fp[0]=fp[1]=1;
    bool FF=0;
    if(!fun(fp,x))
    {
        print(fp,x);FF=1;
    }
    fp[0]=fp[1]=0;
    if(!fun(fp,x)&&FF==0)
    {
        print(fp,x);FF=1;
    }
    fp[0]=1;fp[1]=0;
    if(!fun(fp,x)&&FF==0)
    {
        print(fp,x);FF=1;
    }
    fp[0]=0,fp[1]=1;
    if(!fun(fp,x)&&FF==0)
    {
        print(fp,x);FF=1;
    }
    if(!FF)cout<<"-1";
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 896
import sys 

string1 = str(input())
string2 = str(input())

n, m = len(string2), len(string1) 

ans = sys.maxsize 
for i in range(m - n + 1): 
    minRemovedChar = 0 
    for j in range(n): 
        if (string2[j] != string1[i + j]): 
            minRemovedChar += 1
    ans = min(minRemovedChar, ans) 

print(ans)
	

Measured memory_bytes: 8948
N = int(input())
SP = []
for _ in range(N):
    SP.append([i for i in input().split()])
for n in range(N):
    SP[n][1] = str(100 - int(SP[n][1])).rjust(3,'0')
SP2 = []
for n in range(N):
    SP2.append(SP[n][0]+SP[n][1])
ans = sorted(range(len(SP2)), key=lambda k: SP2[k])
for i in ans:
    print(i+1)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];

		int num, maxNum = -1, nextMaxNum = -1;
		boolean duplicate = false;
		for (int i = 0; i < N; i++) {
			num = sc.nextInt();

			if (num > maxNum) {
				nextMaxNum = maxNum;
				maxNum = num;
				duplicate = false;
			} else if (num == maxNum) {
				duplicate = true;
			} else {
				nextMaxNum = Math.max(nextMaxNum, num);
			}
			A[i] = num;
		}

		for (int i = 0; i < N; i++) {
			if (A[i] == maxNum && !duplicate) {
				System.out.println(nextMaxNum);
			} else {
				System.out.println(maxNum);
			}
		}
	}

}


Measured memory_bytes: 84028
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
llint f(int x, vector<llint> &s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	return  s[x] = f(x - 1, s) + f(x - 2, s);
	
}

//aとｂの最大公約数を求めるよ！
llint gcd(llint a, llint b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {
	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}
void press(string& v) { v.erase(unique((v).begin(), (v).end()), v.end()); }

llint min(llint a, llint b) {
	if (a < b)return a;
	return b;
}

int main() {
	ll a;
	cin >> a;
	ll s=sqrt(a);
	llint ans = 0;
	rep(i, 1, s + 1) {
		if (a % i == 0)ans = i + a / i - 2;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++)
    {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3])
        {
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fn main() {
  let s: String = get::val();
  let p = s.chars().collect::<Vec<_>>().windows(2).any(|w|w[0]=='A'&&w[1]=='C');
  println!("{}", if p {"Yes"} else {"No"});
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    buf.trim().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let mut it = buf.trim().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    let mut it = buf.trim().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<vector>
using namespace std;
int main()
{
	int n, x = 0, y = 0, ans = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n / 2; i++)
	{
		if (s.at(0 + y) == s.at(n / 2 + y))
		{
			ans++;
			y++;
		}
	}
	if (ans * 2 == n)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n, k = list(map(int,input().split()))
    A = list(map(int,input().split()))
    for i in range(n - k):
        if A[i] < A[i + k]:
            print("Yes")
        else: print("No")   
    return 0

if __name__ == "__main__":
    main()

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int dr[]={0,1,0,-1,0};

int main(){
	int n;
	cin >>n;
	
	map<int,int> mp;
	for(int i=1; i<=n && i*(i+1) <= 2*n;i++){
		mp[i*(i+1) / 2] = i;
	}
	//for(auto x :mp) printf("%d:%d, ",x.first,x.second); puts("");
	if( !mp.count(n)){ puts("No"); return 0;}
	int  no = mp[n];
	
	vector<VI> zs(no+1, VI(no, -1));
	auto it=mp.begin(); 
	zs[0][0]= zs[1][0] =1;
	for(auto x: mp){
		int i=x.second - 1;
		int c= x.first;
		repr(j,i,0){
			zs[i+1][j] = zs[j][i] = c--;
		}
	}
	
	//for(auto xl: zs){for(auto x :xl) printf("%2d, ",x); puts("");}

	puts("Yes");
	printf("%d\n", no+1);
	for(auto xl: zs){
		printf("%d ", no);
		for(auto x :xl) printf("%d ",x);
		puts("");
	}
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
inline void _add(int &a,int b)
{
    if((a+=b)>=mod)a-=mod;
}
inline int add(int a,int b)
{
    if((a+=b)>=mod)a-=mod;
    return a;
}
inline int dec(int a,int b)
{
    if((a-=b)<0)a+=mod;
    return a;
}
inline int mult(int a,int b)
{
    ll t=(ll)a*b;
    if(t>=mod)t%=mod;
    return t;
}
inline int power(int a,int b)
{
    int out=1;
    while(b)
    {
        if(b&1)out=mult(out,a);
        a=mult(a,a);
        b>>=1;
    }
    return out;
}
char s[310];
int f[310][310][310],n,m,K;
int main()
{
    scanf("%s%d",s+1,&K);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)
    {
        s[i]-='0';
        m+=!s[i];
    }
    if(!m||m==n)
    {
        puts("1");
        return 0;
    }
    f[0][0][0]=1;
    int cnt=0,c=0,precnt=0;
    for(int i=n;i>=1;i--)
    {
        cnt+=s[i];
        if(!s[i])
        {
            for(int j=0;j<=precnt;j++)
            {
                for(int k=0;k<=j;k++)
                {
                    if(f[c][j][k])
                    {
                        int trs=f[c][j][k];
                        for(int l=1;l<=k;l++)_add(f[c+1][j][k-l],trs);
                        for(int l=0;l+j<=K&&l<=cnt-precnt;l++)_add(f[c+1][j+l][k+l],trs);
                    }
                }
            }
            c++;
            precnt=cnt;
        }
    }
    int res=0;
    for(int i=0;i<=precnt&&i<=K;i++)
        for(int j=0;j<=i;j++)res=add(res,f[c][i][j]);
    printf("%d\n",res);
    return 0;
}

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

int dp[1001][1001];
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string a, b; cin >> a >> b;
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	rep(i, a.size() + 1)rep(j, b.size() + 1) {
		if (i < a.size()) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + 1);
			if (j < b.size()) {
				if (a[i] == b[j])dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
			}
		}
		if (j < b.size())dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
	}
	printf("%d\n", dp[a.size()][b.size()]);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main(){
  cin.sync_with_stdio(false);
  ll k;
  cin >> k;
  set<P> st;
  deque<P> deq;
  deq.push_front(mkp(1,1));
  ll ans;
  while(deq.size()){
    P now = deq.front();deq.pop_front();
    if(st.count(now))continue;
    st.insert(now);
    if(now.fi == 0){
      ans = now.se;
      break;
    }
    deq.push_front(mkp((now.fi*10)%k, now.se));
    deq.push_back(mkp((now.fi+1)%k, now.se+1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 21504
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
int D[60];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> D[i];
  }
  int cnt[13];
  fill(cnt, cnt+13, 0);
  cnt[0] = 1;
  for (auto i = 0; i < N; ++i) {
    cnt[D[i]]++;
  }
  if (cnt[0] >= 2 || cnt[12] >= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (auto i = 1; i <= 11; ++i) {
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;      
    }
  }
  int res = 0;
  for (auto x = 0; x < (1 << 13); ++x) {
    set<int> S;
    for (auto i = 0; i <= 12; ++i) {
      if (cnt[i] == 2) {
        S.insert(i);
        S.insert((24-i)%24);
      } else if (cnt[i] == 1) {
        if (((x >> i) & 1) == 1) {
          S.insert(i);
        } else {
          S.insert((24-i)%24);
        }
      } else {
        assert(cnt[i] == 0);
      }
    }
    int ans = 100;
    for (auto e : S) {
      for (auto f : S) {
        if (e != f) {
          int sa = abs(e-f);
          sa = min(sa, 24-sa);
          ans = min(ans, sa);
        }
      }
    }
    res = max(res, ans);
  }
  cout << res << endl;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int tmp = 0;
		long result = 0;
		while(tmp <= N) {
			if(tmp % 3 == 0 || tmp % 5 == 0) {
				
			} else {
				result += tmp;
			}
			tmp++;
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 25648
# from fractions import gcd
# P = 10**9+7
# N = int(input())
# S = list(map(int, input().split()))

# l = {2:0}
# for num in S:
#     temp = num
#     M = temp//2+2
#     cnt = 0
#     while temp%2 == 0:
#         cnt += 1
#         temp //= 2
#     l[2] = max(l[2], cnt)
#     i = 3
#     while temp > 1 and i < M:
#         cnt = 0
#         while temp%i == 0:
#             cnt += 1
#             temp //= i
#         if cnt > 0:
#             if i in l:
#                 l[i] = max(l[i], cnt)
#             else:
#                 l[i] = cnt
#         i += 2
#     if temp > 1:
#         if temp in l:
#             l[temp] = max(l[temp], 1)
#         else:
#             l[temp] = 1
    
    
# ans = 0
# for i in range(N):
#     ans = (temp//S[i]+ans)%P
# print(ans)



from fractions import gcd
P = 10**9+7
N = int(input())
S = list(map(int, input().split()))
 
temp = S[0]
for i in range(1, N):
    temp = temp*S[i] // gcd(temp, S[i])
temp %= P
 
ans = 0
for num in S:
    ans = ((temp*pow(num, P-2, P))%P+ans)%P
print(ans)

Measured memory_bytes: 6116
S = str(input())
N = len(S)
 
head = round((N-1)/2)
end = round((N+3)/2-1)

headS = S[:head]
endS = S[end:]

if S==S[::-1] and headS == headS[::-1] and endS == endS[::-1]:
	print('Yes')
else:
  	print('No')

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

// dp[i][j][k][l] :=  i: 上位 i 桁目まで決定
//                    j: small(数字を自由に選べる)か
//                    k: started(数字を書き込んだ)か
//                    l: {3,5,7} を選んだかのflag
//                    としたときの753数の数
int dp[11][2][2][8];

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

  string n;
  cin >> n;

  int len = n.size();
  dp[0][0][0][0] = 1;
  for (int i = 0; i < len; ++i)
  {
    for (int j = 0; j < 2; ++j)
    {
      for (int k = 0; k < 2; ++k)
      {
        for (int l = 0; l < 8; ++l)
        {
          if (!dp[i][j][k][l]) continue;

          if (j == 1)                  // small ([0, 9] から数字を選べる)か
          {
            if (k == 0)                // not started (数字を書き込んでいない)か
              dp[i + 1][1][0][0] += dp[i][1][0][0];                // nothing

            dp[i + 1][1][1][l | 1] += dp[i][1][k][l];              // +3
            dp[i + 1][1][1][l | 2] += dp[i][1][k][l];              // +5
            dp[i + 1][1][1][l | 4] += dp[i][1][k][l];              // +7
          }
          else                         // not small ([0, d] から数字を選べる)か
          {
            int d = n[i] - '0';

            if (k == 0)                // not started (数字を書き込んでいない)か
              dp[i + 1][1][0][0] += dp[i][0][0][0];                // nothing

            if (d == 3) dp[i + 1][0][1][l | 1] += dp[i][0][k][l];  // +3
            if (3 < d)  dp[i + 1][1][1][l | 1] += dp[i][0][k][l];  // +3
            if (d == 5) dp[i + 1][0][1][l | 2] += dp[i][0][k][l];  // +5
            if (5 < d)  dp[i + 1][1][1][l | 2] += dp[i][0][k][l];  // +5
            if (d == 7) dp[i + 1][0][1][l | 4] += dp[i][0][k][l];  // +7
            if (7 < d)  dp[i + 1][1][1][l | 4] += dp[i][0][k][l];  // +7
          }
        }
      }
    }
  }

  int ans = dp[len][0][1][7] + dp[len][1][1][7];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def sumDesire(C, d, last):
    sumA = 0
    for i in range(26):
        sumA += C[i] * (d - last[i])
    return sumA


def resolve():
    from collections import defaultdict
    D = int(input())
    C = [int(i) for i in input().split()]
    SD = [list(map(int, input().split())) for _ in range(D)]
    T = [int(input()) for _ in range(D)]

    last = defaultdict(int)
    ans = 0
    for i in range(D):
        ans += SD[i][T[i] - 1]
        last[T[i] - 1] = i + 1
        ans -= sumDesire(C, i + 1, last)
        print(ans)


resolve()


Measured memory_bytes: 9668
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll n;
int main() {
    while(cin>>n, n!=0){
        ll s;
        ll mx=-LLINF, mn=LLINF, sum=0;
        REP(i, 0, n){
            cin>>s;
            mx=max(mx, s);
            mn=min(mn, s);
            sum+=s;
        }

        cout<<(sum-mx-mn)/(n-2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 2940
x = list(input())
num = int(input())

for _ in range(num):
    v = input().split()
    order = v[0]
    if order == 'replace':
        a, b, c =v[1:]
        a, b = int(a), int(b)
        del x[a:b+1]
        for n, v in enumerate(list(c)):
            x.insert(a + n, v)
    elif order == 'print':
        a, b = map(int, v[1:])
        print(''.join(x[a:b+1]))
    elif order == 'reverse':
        a, b = map(int, v[1:])
        c = x[a:b+1]
        del x[a:b+1]
        for n, v in enumerate(reversed(list(c))):
            x.insert(a + n, v)


Measured memory_bytes: 5624
/*Hanafuda Shuffle*/
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;

int main(void){
  int d=0;
  int n,r,p,c;
  while(d==0){
    cin >> n >> r;
    if(n==0 && r==0)break;
    vector<int> a(n,0);
    for(int i=0;i<n;i++){
      a[i]=i+1;
    }
    reverse(a.begin(),a.end());
    for(int i=0;i<r;i++){
      cin >> p >> c;
      rotate(a.begin(),a.begin()+p-1,a.begin()+p-1+c);
    }
    cout << a[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<queue>
#define black 2
#define white 0
#define gray 1
using namespace std;
int matrix[101][101];
int n;
int temp;
int d[101]={-1};
int color[101]={white};
int main(){
    for(int i=0;i<101;i++){
        for(int j=0;j<101;j++)
            matrix[i][j]=0;
    }
    cin>>n;
    int x,y;
    for(int i=0;i<n;i++){
        cin>>x>>temp;
        for(int j=0;j<temp;j++){
            cin>>y;
            matrix[x][y]=1;
        }
    }
    queue <int> q;
    q.push(1);
    for(int i=0;i<=n;i++)
      d[i]=-1;
    color[1]=gray;
    d[1]=0;

    while(!q.empty()){
        temp=q.front();
        for(int i=1;i<=n;i++){
            if(matrix[temp][i]==1&&color[i]==white){
                q.push(i);
                color[i]=gray;
                d[i]=d[temp]+1;
            }
        }
        color[temp]=black;
        q.pop();
    }
    for(int i=1;i<=n;i++)
        cout<<i<<" "<<d[i]<<endl;
    return 0;
}



Measured memory_bytes: 3156
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.next());
        int[] ballIndexes = new int[n];
        long[] cnt = new long[200005];
        for(int i = 0; i < n; ++i) {
            ballIndexes[i] = Integer.parseInt(sc.next());
            ++cnt[ballIndexes[i]];
        }

        long allPatterns = 0;
        for(int i = 0, f = cnt.length; i < f; ++i) {
            allPatterns += cnt[i] * (cnt[i] - 1L) / 2L;
        }

        for(int i = 0; i < n; ++i) {
            int bIndex = ballIndexes[i];
            long count = cnt[bIndex];
            System.out.println(allPatterns - (count - 1));
        }
    }
}

Measured memory_bytes: 76452
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
int bsr(uint x){
	if(x==0) return -1;
	return 31 ^ __builtin_clz(x);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	rep(i,N){
		for(int j=i+1;j<N;j++){
			cout << bsr(i^j) +1 << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
  int n; 
  string s;
  cin >> n >> s;
  for(int i=0; i<2*n; i++){
    if((i + (s[i] == 'W')) % 2 == 0){
      s[i] = 'L';
    }
    else{
      s[i] = 'R';
    }
  }
  if(count(s.begin(), s.end(), 'L') != n) cout << 0 << endl;
  else{
    ll ans = 1;
    int left = 0;
    for(int i=0; i<2*n; i++){
      if(s[i] == 'L') left++;
      else{
        ans *= left;
        left--;
        ans %= MOD;
      }
    }
    for(int i=1; i<n+1; i++){
      ans *= i;
      ans %= MOD;
    }
    cout << ans << endl;
  }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int a,aa,b,bb;
  cin >> a >> aa >> b >> bb;
  a != b ? cout << 1 << endl : cout << 0 << endl;
  


  

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
H, W, K = map(int, input().split())
B = {}
for _ in range(K):
    r, c, v = map(int, input().split())
    B[(r, c)] = v

dp = [[0]*(W+1) for _ in range(4)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if (i, j) in B:
            v = B[(i, j)]
            dp[0][j] = max(dp[0][j-1], dp[0][j], dp[1][j], dp[2][j], dp[3][j])
            dp[1][j] = max(dp[1][j-1], dp[0][j]+v)
            dp[2][j] = max(dp[2][j-1], dp[1][j-1]+v)
            dp[3][j] = max(dp[3][j-1], dp[2][j-1]+v)
        else:
            dp[0][j] = max(dp[0][j-1], dp[0][j], dp[1][j], dp[2][j], dp[3][j])
            dp[1][j] = dp[1][j-1]
            dp[2][j] = dp[2][j-1]
            dp[3][j] = dp[3][j-1]

print(max(dp[i][-1] for i in range(4)))


Measured memory_bytes: 107924
def prime_factor(num):
	count = 0
	bak = num
	for i in range(2, num):
		if(i*i>num):
			break
		if(bak%i == 0):
			count += 1
		while(bak%i == 0):
			bak = bak//i
	if (bak > 1):
		count += 1
	return count



def calgcd(a, b):
	if(a%b == 0):
		return b
	else:
		return calgcd(b, a%b)



A, B = map(int, input().split())
gcd = calgcd(A, B)
print(prime_factor(gcd) + 1)

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

#define ll long long
#define ar array
 
using namespace std;

int main() {

    int a, b, temp = 0, i = 0;
    vector <int> vet;
    
    cin >> a;
	
	while(a--){
		cin >> b;
		
		if(temp <= b){
			temp = b;
			i++;
		}
	}
	
	cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    if (s.contains("a") && s.contains("b") && s.contains("c")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <functional>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<int,int> P;

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

int main(){
  int c[3][3];
  int a[3];
  int b[3];
  int f = true;

  for( int i = 0; i < 3; ++i){
    for( int j = 0; j < 3; ++j){
      cin >> c[i][j];
    }
  }

  b[0] = 0;
  for( int i = 0; i < 3; ++i){
    a[i] = c[i][0];
  }

  int tmp0, tmp1, tmp2;
  tmp0 = c[0][1] - a[0];
  tmp1 = c[1][1] - a[1];
  tmp2 = c[2][1] - a[2];

  if( tmp0 != tmp1 || tmp1 != tmp2 || tmp0 != tmp2){
    f = false;
  }

  tmp0 = c[0][2] - a[0];
  tmp1 = c[1][2] - a[1];
  tmp2 = c[2][2] - a[2];

  if( tmp0 != tmp1 || tmp1 != tmp2 || tmp0 != tmp2){
    f = false;
  }

  if(f){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

 }


Measured memory_bytes: 256
<?php  
fscanf(STDIN,"%d%d",$x,$n);
$p_li = explode(" ",trim(fgets(STDIN)));
foreach($p_li as $v) $array[$v]++;
//print_r($array);

for($i=-1;$i<=101;$i++){
  if(!isset($array[$i])){
    $diffs[$i] = abs($i-$x);
  }
}

asort($diffs);

//print_r($diffs);
echo key($diffs);
//$juge ? echo 'YES' : echo 'NO';
//echo $n;

Measured memory_bytes: 16152