akhauriyash/Code-Regression huggingface dataset:
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(cnt, fld)
  erase = 8.times.map{ [nil] * 14 }
  (1..6).each do |i|
    (1..12).each do |j|
      if fld[i][j] =~ /[^O.]/ && erase[i][j].nil?
        erase[i][j] = false
        puyo_connector(i, j, fld, erase){ |arr|
          arr.each do |s, t|
            D.each do |x, y|
              p, q = s + x, t + y
              erase[p][q] = true if fld[p][q] == 'O'
            end
            erase[s][t] = true
          end
        }
      end
    end
  end
  if erase.flatten.any?{ |v| v } then puyo_rensa(cnt + 1, puyo_eraser(fld, erase))
  else cnt
  end
end

def puyo_connector(i, j, fld, erase)
  arr = [[i, j]]
  ret = [[i, j]]
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if erase[p][q].nil? && fld[i][j] == fld[p][q]
        erase[p][q] = false
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret) if ret.size >= 4
end

def puyo_eraser(fld, erase)
  (1..6).each do |i|
    fld[i].map!.with_index{ |c, j| c unless erase[i][j] }.compact!
    (14 - fld[i].size).times{ fld[i].unshift('.') }
  end
  fld
end

gets.to_i.times do
  fld = 8.times.map{ ['.'] * 14 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[j+1][i+1] = c
    end
  end
  p puyo_rensa(0, fld)
end

Measured memory_bytes: 9232
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN      
const ll mod=1e9+7;
const int N=1e5+4;

int main()                  
{
	string s; cin>>s;
  
  	int num=0,n=(int)s.size();
  
  	rep(i,0,n)
    {
      int here = s[i]-'0'; 
      
      num=(num*10+here)%9;
    }
  
  	if(num==0)
     cout<<"Yes";
  	else
     cout<<"No";
  
    return 0;
}

Measured memory_bytes: 3708
N = int(input())
e = [0] * (N+1)
for i in range(2, N+1):
  cur = i
  for j in range(2, i+1):
    while cur % j == 0:
      e[j] += 1
      cur //= j

def num(m):
  return len(list(filter(lambda x: x >= m-1, e)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)

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

int main(void){
  int N, a, b, c, d ;
  cin >> N;
  a = N / 1000;
  b = (N-a*1000) / 100;
  c = (N-(a*10+b)*100) / 10;
  d = N-(a*100+b*10+c)*10;
  
  if( a == b && b == c || b == c && c ==d ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
N = int(input())
A = list(map(int, input().split()))
minus = 0
minA = 10**9+1
absSum = 0
for i in range(N):
    minus += A[i]<0
    minA = min(abs(A[i]), minA)
    absSum += abs(A[i])
if(minus%2==1):
    print(absSum-2*minA)
else:
    print(absSum)


Measured memory_bytes: 14412
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef long long ll;
using namespace std;
int main()
{
     int n,m;
     cin>>n>>m;
     int cnt=0;
     while(n--)
     {
         int  x,y;
         cin>>x>>y;
         double temp=hypot(x,y);

         if(temp<=m)
            cnt++;
     }
     cout<<cnt<<endl;

return 0;

}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, r;
  cin>>n>>r;
  if(n>=10){
    cout<<r<<'\n';
    return 0;
  }
  cout<<r+100*(10-n)<<'\n';
  return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            int n = s.length();

            int[] dp = new int[1 << 26];
            Arrays.fill(dp, Integer.MAX_VALUE / 2);
            dp[0] = 0;

            int hash = 0;
            for (int i = 0; i < n; i++) {
                hash ^= 1 << s.charAt(i) - 'a';

                for (int j = 0; j < 26; j++) {
                    dp[hash] = Math.min(dp[hash], dp[hash ^ 1 << j] + 1);
                }
            }

            out.println(Math.max(1, dp[hash]));
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 292436
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int arry[200000 + 1];

int main(){
	memset(arry, 0, sizeof(arry));
	int n;
	cin >> n;
	for (int i = 2; i <= n; ++i){
		int v;
		cin >> v;
		++arry[v];
	}
	for (int i = 1; i <= n; ++i){
		cout << arry[i] << endl;
	}
}

Measured memory_bytes: 4416
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    vector<int>v;
    while(n>0)
    {
        v.push_back((n+25)%26+1);
        n=n-((n+25)%26+1);
        n=n/26;
    }
    reverse(v.begin(),v.end());
    for(int x : v) cout<<(char)(x-1+'a');
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
const long long MOD = 1e9+7;
const long long INF = 1e15;
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int N, K;
    cin >> N >> K;
    int P[N];
    rep(i, N) cin >> P[i];
    int count = 0;
    int pos = 0;
    while(pos < N){
        int j = 1;
        while(pos+j < N && P[pos+j-1] < P[pos+j]) j++;
        if(j >= K) count++;
        pos += j;
    }
    set<int> s;
    rep(i, K) s.insert(P[i]);
    int ans = 1;
    rep(i, N-K){
        s.insert(P[i+K]);
        set<int>::iterator ite1, ite2;;
        ite1 = s.find(P[i]);
        ite2 = s.find(P[i+K]);
        ite2++;
        if(ite1 != s.begin() || ite2 != s.end()) ans++;
        s.erase(P[i]);
    }
    if(count >= 2) ans -= count-1;
    cout << ans << endl;
}

Measured memory_bytes: 10368
n,*a=map(int,open(0).read().split())
ans=1
tmp=0
for i in range(1,n):
  if (a[i]-a[i-1])*tmp<0:
    ans+=1
    tmp=0
  elif not a[i]-a[i-1]==0:
    tmp=a[i]-a[i-1]
print(ans)

Measured memory_bytes: 14052
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];

int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	cin >> N;

	while(N >= 0) {
		if (N % 7 == 0) {
			ans = 1;
			break;
		}
		N = N - 4;
	}
	if (ans==0) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	char qq;
	cin >> qq;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;

int main () {
    int n; cin >> n;
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < n; j++) {
            if (s[i] == 'Z') s[i] = 'A';
            else s[i]++;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a*b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] c = new int[m+1];
		for(int i = 1; i <= m; i++) c[i] = sc.nextInt();
		
		int[][] dp = new int[m+1][n+1];
		Arrays.fill(dp[0], Integer.MAX_VALUE);
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j <= n; j++){
				if(j < c[i+1]){
					dp[i+1][j] = dp[i][j];
				}else if(j == c[i+1]){
					dp[i+1][j] = 1;
				}else{
					dp[i+1][j] = Math.min(dp[i][j], dp[i+1][j-c[i+1]] + 1);
				}
			}
		}
		
		System.out.println(dp[m][n]);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}



Measured memory_bytes: 29388
#!/usr/bin/env python3

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    s = read(str)
    if s.endswith("s"):
        s += "es"
    else:
        s += "s"
    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=2e3;
char map[N+10][N+10];
int sum[N+10][N+10],lne[N+10][N+10],row[N+10][N+10];
int main(){
	int n=read(),m=read(),q=read();
	for (int i=1;i<=n;i++){
		scanf("%s",map[i]+1);
		for (int j=1;j<=m;j++){
			if (map[i][j]=='1'){
				sum[i][j]=1;
				if (map[i][j-1]=='1')	lne[i][j]=1;
				if (map[i-1][j]=='1')	row[i][j]=1;
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			lne[i][j]+=lne[i-1][j]+lne[i][j-1]-lne[i-1][j-1];
			row[i][j]+=row[i-1][j]+row[i][j-1]-row[i-1][j-1];
		}
	}
	for (int i=1;i<=q;i++){
		int x1=read(),y1=read(),x2=read(),y2=read(),Ans=0;
		Ans+=sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
		Ans-=lne[x2][y2]-lne[x1-1][y2]-lne[x2][y1]+lne[x1-1][y1];
		Ans-=row[x2][y2]-row[x1][y2]-row[x2][y1-1]+row[x1][y1-1];
		printf("%d\n",Ans);
	}
	return 0;
}

Measured memory_bytes: 53120
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    ll H, W;
    cin >> H >> W;

    if (H == 1 && W == 1)
        cout << 1 << endl;
    else if (H == 1)
        cout << W - 2 << endl;
    else if (W == 1)
        cout << H - 2 << endl;
    else {
        //頂点4回 表
        //辺6回   表
        //内側9回 (H-2)*(W-2) -> 裏
        cout << (H - 2) * (W - 2) << endl;
    }
}


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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mxx=1e9+7;

int main()
{
    fast
   
    int n;
    cin>>n;
    ll tot=0,ans=0;
    ll a[n];
    for(int i=0;i<n;i++)
    {
    	 cin>>a[i];
    	 tot+=a[i];
    }

    for(int i=0;i<n;i++)
    {    
    	tot-=a[i];
    	ans+=((tot%mxx)*(a[i]%mxx))%mxx;
    	ans%=mxx;
    }
    cout<<ans;
   
}

Measured memory_bytes: 5200
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k, q = LI()
    ans = [0 for i in range(n)]
    for i in range(q):
        a = II()
        ans[a-1] += 1
    for i, v in enumerate(ans):
        if k > (q - v):
            print("Yes")
        else:
            print("No")

if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
	int N,M,X,Y,xmax, ymin;
	cin >> N >> M >> X >> Y;
	xmax = X; ymin = Y;

	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		if (x > xmax) {
			xmax = x;
		}
	}
	for (int i = 0; i < M; i++) {
		int y; cin >> y;
		if (y < ymin) {
			ymin = y;
		}
	}
	if (xmax < ymin) {
		cout << "No War";
	}
	else {
		cout << "War";
	}
	return 0;
}

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

vector<int> adj[100005],down(100005),up(100005),children[100005],downs[100005],pre[100005],suff[100005];

void dfs(int s,int par)
{
	ll tmp=0;
	for(auto i:adj[s])
	{
		if(i!=par)
		{
			dfs(i,s);
			children[s].push_back(i);
			downs[s].push_back(down[i]);
			tmp=(tmp+down[i]+tmp*down[i])%MOD;
		}
	}
	
	down[s]=(tmp+1)%MOD;
}

void dfs2(int s,int par)
{
	for(int i=0;i<children[s].size();i++)
	{
		ll tmp=0;
			
		if(i)
		{
			tmp=(tmp+pre[s][i-1]+tmp*pre[s][i-1])%MOD;
		}
			
		if(i!=children[s].size()-1)
		{
			tmp=(tmp+suff[s][i+1]+tmp*suff[s][i+1])%MOD;
		}
		
		if(s!=1)
		{
			tmp=(tmp+up[s]+tmp*up[s])%MOD;
		}
		
		up[children[s][i]]=(tmp+1)%MOD;
			
		dfs2(children[s][i],s);
			/*children[s].push_back(i);
			downs[s].push_back(down[i]);
			tmp=(tmp+down[i]+tmp*down[i])%MOD;*/
	}
	
	//down[s]=(tmp+1)%MOD;
}

main()
{
	int n,x,y;
	cin>>n>>MOD;
	
	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	
	dfs(1,-1);
	
	for(int i=1;i<=n;i++)
	{
		ll tmp=0;
		for(int j=0;j<downs[i].size();j++)
		{
			tmp=(tmp+downs[i][j]+tmp*downs[i][j])%MOD;
			pre[i].push_back(tmp);
		}
		
		tmp=0;
		for(int j=downs[i].size()-1;j>=0;j--)
		{
			tmp=(tmp+downs[i][j]+tmp*downs[i][j])%MOD;
			suff[i].push_back(tmp);
		}
		
		reverse(suff[i].begin(),suff[i].end());
	}
	
	dfs2(1,-1);
	
	/*for(int i=1;i<=n;i++)
	cout<<i<<" "<<down[i]<<endl;
	
	for(int i=1;i<=n;i++)
	cout<<i<<" "<<up[i]<<endl;*/
	
	for(int i=1;i<=n;i++)
	{
		ll tmp=(down[i]-1+MOD)%MOD;
		tmp=(tmp+up[i]+tmp*up[i]+1)%MOD;
		
		cout<<tmp<<endl;
	}
}

Measured memory_bytes: 34560
def sisuu(X, n):
    if (int(X/n)):
        return sisuu(int(X/n), n) + str(X%n)
    return  str(X%n)

N, K = [int(x) for x in input().split()]

hennkan = sisuu(N, K)
ketasuu = len(str(hennkan))

print(ketasuu)


Measured memory_bytes: 2940
n=int(input())
l=[list(map(int,input().split()))for i in[0]*n]
a=[0 for i in[0]*n];d=0;k=n*(n-1)
while sum(a)<k and -1<d<9999:
  L=[0 for i in[0]*n];y=0;d+=1
  for i in range(n):
    if L[i]<1 and a[i]<n-1:
      x=l[i][a[i]]-1
      if l[x][a[x]]-1==i and L[x]<1:
        a[i]+=1;a[x]+=1;L[i]=1;L[x]=1;y+=1
  if y<1:d=-1
print([k//2,d][d<9999])

Measured memory_bytes: 56028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
    return;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <stack> 
#include <cctype>   //  tolower toupper

typedef long long LL;
using namespace std;

int main()
{
	int a4,a2,a3;
	int N,tmp;
	a4 = 0,a2 = 0,a3 = 0;
	scanf("%d",&N);
	for(int i = 0;i < N;++i){
		scanf("%d",&tmp);
		if(tmp%4 == 0)
			++a4;
		else if(tmp%2 == 0)
			++a2; 
		else
			++a3;
	} 
	if(a2 == 0 && a4+1 >= a3)
		cout << "Yes" << endl;
	else if(a2 > 0 && a3 <= a4) 
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i,j,N,W,**C,*v,*w,v1,w1;
  
  if (scanf("%d %d",&N,&W)<2) exit(1);
  C = malloc((N+1)*sizeof(int*));
  for (i=0;i<N+1;i++) C[i] = malloc((W+1)*sizeof(int));
  for (i=0;i<N+1;i++) {
    for (j=0;j<W+1;j++) C[i][j] = 0;
  }
  
  v = malloc((N+1)*sizeof(int));
  w = malloc((N+1)*sizeof(int));
  for (i=1;i<N+1;i++) {
    if (scanf("%d %d",&v1,&w1)<2) exit(1);
    v[i] = v1; w[i] = w1;
  }
  
  for (i=1;i<N+1;i++) {
    for (j=1;j<W+1;j++) {
      if (j < w[i]) {
        C[i][j] = C[i-1][j];
        continue;
      }
      if (C[i-1][j] > C[i-1][j-w[i]]+v[i]) C[i][j] = C[i-1][j];
      else C[i][j] = C[i-1][j-w[i]]+v[i];
    }
  }
  
  printf("%d\n",C[N][W]);
  
  return 0;
}

Measured memory_bytes: 4544
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
L = dict(Counter([i+A[i] for i in range(N)]))
R = dict(Counter([i-A[i] for i in range(N)]))
cnt = 0
for x in L:
    cnt += L[x]*R.get(x, 0)
print(cnt)

Measured memory_bytes: 199432
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	
	vector<int> A(N);
	REP(i, N) scanf("%d", A.begin() + i);
	
	int ans = INF;
	vector<int> ord(N);
	REP(i, N) ord[i] = i;
	sort(ALL(ord), [&](int x, int y) {
		return A[x] < A[y];
	});
	
	for (int i : ord) {
		int p = 0;
		vector<int> v;
		while (p < N) {
			if (A[i] > A[p]) { p++; continue; }
			int cnt = 0;
			vector<int> cur;
			while (p + cnt < N && A[i] <= A[p + cnt]) {
				cur.emplace_back(A[p + cnt]);
				cnt++;
			}
			if (cnt >= K) {
				sort(ALL(cur));
				REP(j, cur.size() - K + 1) v.emplace_back(cur[j]);
			}
			p += cnt;
		}
		if (v.size() < Q) break;
		sort(ALL(v));
		chmin(ans, v[Q - 1] - v[0]);
	}
	
	cout << ans << endl;
	
// REP(i, N) printf("%d %d\n", A[ord[i]], ord[i]);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define log(x) cout << (#x) << " is " << (x) << endl

vector<pair<int,long> > items;//{weight , value}

// long** memory = NULL;
 
long memory[100001][101] = {0,};

long KPW(int w,int i){
    if(w < 0){
        return INT_MIN;
    }
    if(i<0){
        return 0;
    }
    if(memory[w][i]>0){
        return memory[w][i];
    }
    return memory[w][i] = max(items[i].second + KPW(w - items[i].first , i-1) , KPW(w,i-1));
}

// long KPW(int W,int n,vector<int>& val,vector<int>& wt) {
//     int i, w;
//     long K[n+1][W+1]; 
  
//     // Build table K[][] in bottom up manner 
//     for (i = 0; i <= n; i++) {
//         for (w = 0; w <= W; w++){
//             if (i==0 || w==0) 
//                 K[i][w] = 0; 
//             else if (wt[i-1] <= w) 
//                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
//             else
//                 K[i][w] = K[i-1][w]; 

//             cout<<K[i][w]<<" ";
//         }
//         cout<<endl;
//     } 
//     return K[n][W]; 
// } 

template<typename T>
void min_self(T& a,T b){a = min(a,b);}
template<typename T>
void max_self(T& a,T b){a = max(a,b);}

int main(){
    int n;
    ll w;
    cin>>n>>w;
    vector<int> val(n);
    vector<ll> wt(n);
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }

    int total_val = accumulate(val.begin(),val.end(),0);
    // log(total_val);
    const ll inf = 1e18L+1;
    vector<ll> KPW(total_val+1 , inf);  // -> stores weight
    KPW[0] = 0;
    for(int item = 0;item < n;item ++){
        for(int value_in = total_val - val[item] ;value_in >=0 ; --value_in){
            min_self(KPW[value_in + val[item]],KPW[value_in] + wt[item]);
        }
    }

    int ans = 0;
    for(int v = 0;v <= total_val ; v++){
        // cout<<"v : "<<v<<" w: "<<KPW[v]<<endl;
        if(KPW[v] <= w){
            ans = v;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 1024
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    n,m = map(int, stdin.readline().rstrip().split())
    x = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if n>m:
        print(0)
        exit()
    spl = n-1
    sa = [0]*(m-1)
    x.sort()
    for i in range(m-1):
        sa[i] = x[i+1] - x[i]
    sa.sort()
    i = m-n
    print(sum(sa[:i]))



main()


Measured memory_bytes: 13960
ary = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
       1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ary[int(input())-1])


Measured memory_bytes: 38384
n,m=map(int,input().split())
a=[int(j) for j in input().split()]

a.sort(reverse=True)
sum=0

for i in range(0,n):
    sum+=a[i]

temp=sum/(4*m)

count=0

for i in range(0,n):
    if(a[i]<temp):
        break
    else:
        count+=1

if(count>=m):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import java.util.Scanner;


public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int index = Integer.parseInt(sc.nextLine());
        String[] str = sc.nextLine().split(" ");

        for(int loopcnt = str.length; loopcnt > 0; loopcnt--){
            if( loopcnt != 1 ) System.out.print(str[loopcnt-1] + " ");
            else System.out.print(str[loopcnt-1]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26320
n = int(input())
l = [[0, 0] for _ in range(n)]
for i in range(n):
  x, y = map(int, input().split())
  l[i][0] = x
  l[i][1] = y

import math
if n == 2:
  r = math.sqrt((l[1][0]-l[0][0])**2+(l[1][1]-l[0][1])**2)/2
  print(r)
  exit()

ans = float('inf')
import itertools
combs = list(itertools.combinations(range(n), 3))
for comb in combs:
  x0, y0 = l[comb[0]]
  x1, y1 = l[comb[1]]
  x2, y2 = l[comb[2]]
  
  a = x1 - x0
  b = y1 -y0
  p = (x1**2-x0**2+y1**2-y0**2)/2
  
  c = x2 - x0  
  d = y2 -y0
  q = (x2**2-x0**2+y2**2-y0**2)/2
  
  if a*d - b*c == 0:
    continue
  xc = (p*d-q*b)/(a*d-b*c)
  yc = (-p*c+q*a)/(a*d-b*c)
  r = math.sqrt((x0-xc)**2+(y0-yc)**2)
  for i in range(n):
    x, y = l[i]
    if math.sqrt((x-xc)**2+(y-yc)**2) > r:
      break
  else:
    ans = min(ans, r)

combs = list(itertools.combinations(range(n), 2))
for comb in combs:
  x0, y0 = l[comb[0]]
  x1, y1 = l[comb[1]]
  xc = (x0+x1)/2
  yc = (y0+y1)/2
  r = math.sqrt((x0-xc)**2+(y0-yc)**2)
  for i in range(n):
    x, y = l[i]
    if math.sqrt((x-xc)**2+(y-yc)**2) > r:
      break
  else:
    ans = min(ans, r)
print(ans)

Measured memory_bytes: 52844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,c[100005][30][30],q,r[30],ans[100005];
string s[100005];
void dfs(vector<int> x,int l){
	int o=0;
	vector<int>p[26];
	for(int i=0;i<x.size();i++){
		if(l<s[x[i]].size())p[s[x[i]][l]-'a'].PB(x[i]);
		else o++;
	}
	for(int i=0;i<x.size();i++){
		if(s[x[i]].size()<=l)continue;
		ans[x[i]]+=o;
		for(int j=0;j<26;j++){
			c[x[i]][s[x[i]][l]-'a'][j]+=int(p[j].size());
		}
	}
	for(int i=0;i<26;i++)if(p[i].size())dfs(p[i],l+1);
}
int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++)cin>>s[i];
	scanf("%d",&q);
	if(n==1){
		while(q--)printf("1\n");
		return 0;
	}
	vector<int>x;
	for(int i=0;i<n;i++)x.PB(i);
	dfs(x,0);
	while(q--){
		int k;
		scanf(" %d",&k);
		k--;
		int res=ans[k];
		for(int i=0;i<26;i++){
			char t;
			scanf(" %c",&t);
			r[t-'a']=i;
		}
		for(int i=0;i<26;i++){
			for(int j=0;j<26;j++){
				if(r[i]>r[j])res+=c[k][i][j];
			}
		}
		printf("%d\n",res+1);
	}
}

Measured memory_bytes: 358904
import Control.Applicative
import qualified Control.Monad as Monad

main = loopPutNumbers

loopPutNumbers :: IO ()
loopPutNumbers = do
    [x,y] <- map (read :: String -> Int) . words <$> getLine
    Monad.when (x /= 0 || y /= 0) $ do
        putStrLn $ if (x < y)
                    then unwords $ show <$> [x,y]
                    else unwords $ show <$> [y,x]
        loopPutNumbers

Measured memory_bytes: 4112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, result[1000];

void push(int x){
    result[++top]=x;
}
int pop(){
    top--;
    return result[top+1];
}

int main(){
    int a,b;
    char s[100];
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
    return 0;
}




Measured memory_bytes: 2108
import sys
import numpy as np
import itertools

fin = sys.stdin.readline
N, M = [int(elem) for elem in fin().split()]
conditions = [[int(elem)-1 for elem in fin().split()] for _ in range(M)]
p_list = [int(elem) for elem in fin().split()]

count = 0
perm_list = list(range(0, N))
range_list = list(range(0, N+1))

for r in range_list:
    for each_iter in itertools.combinations(perm_list, r):
        each_switchs = np.zeros((N))
        each_iter = list(each_iter)
        each_switchs[each_iter] = 1
        flag = 0
        for i, each_condition in enumerate(conditions):
            each_sum = each_switchs[each_condition[1:]]
            if np.sum(each_sum) % 2 != p_list[i]:
                flag = 1
        if flag == 0:
            count += 1

print(count)


Measured memory_bytes: 14140
n , k = map(int , input().split())
h = list(map(int , input().split()))

dp = [10**10 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j] = min(dp[j] , dp[i] + abs(h[i] - h[j]))
# print(dp),
print(dp[n-1])

Measured memory_bytes: 56544
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
map<pii,int>cnt;
int vis[50];
void solve(){
	int n;
	cin>>n;
	pii p[n];
	rep(i,n){
		int x,y;
		cin>>x>>y;
		p[i]=pii(x,y);
	}
	if(n==1){cout<<1;return;}
	sort(p,p+n);
	vector<pii>pq;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int x=p[j].fi-p[i].fi;
			int y=p[j].se-p[i].se;
			if(!cnt[pii(x,y)])pq.pb(pii(x,y));
			cnt[pii(x,y)]++;
		}
	}
	sort(pq.begin(), pq.end());
	int mn=50;
	for(pii x:pq){
		int res=0;
		//cout<<x.fi<<" "<<x.se<<"p q\n";
		int vis[n];
		for(int i=0;i<n;i++)vis[i]=0;
		for(int i=0;i<n;i++){
			if(vis[i])continue;
			int pre=i;
			res++;
			vis[i]=1;
			while(true){
				int f=0;
				for(int j=i+1;j<n;j++){
					if(vis[j])continue;
					if(p[pre].fi+x.fi==p[j].fi&&p[pre].se+x.se==p[j].se){pre=j;f=1;break;}
				}
				if(!f)break;
				vis[pre]=1;
			}
		}
		mn=min(mn,res);
	}
	cout<<mn;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 384
#!/usr/bin/env python3

import heapq

def main():
    n = int(input())
    nodes = []
    for i in range(n):
        xi, yi = map(int, input().split())
        nodes.append((i, xi, yi))

    adj = [[] for i in range(n)]
    nodes.sort(key=(lambda x: x[1]))
    for j in range(n):
        i = nodes[j][0]
        if j - 1 >= 0:
            i1 = nodes[j - 1][0]
            adj[i].append(i1)
        if j + 1 < n:
            i1 = nodes[j + 1][0]
            adj[i].append(i1)
    nodes.sort(key=(lambda x: x[2]))
    for j in range(n):
        i = nodes[j][0]
        if j - 1 >= 0:
            i1 = nodes[j - 1][0]
            adj[i].append(i1)
        if j + 1 < n:
            i1 = nodes[j + 1][0]
            adj[i].append(i1)
    nodes.sort(key=(lambda x: x[0]))

    res = 0
    q = [(0, 0)]
    visited = [False for i in range(n)]
    while q:
        d, i = heapq.heappop(q)
        if visited[i]:
            continue
        visited[i] = True
        res += d
        for j in adj[i]:
            if visited[j]:
                continue
            heapq.heappush(q, (dist(i, j, nodes), j))
    print(res)

def dist(i, j, nodes):
    _, xi, yi = nodes[i]
    _, xj, yj = nodes[j]
    res = min(abs(xi - xj), abs(yi - yj))
    return res

if __name__ == "__main__":
    main()


Measured memory_bytes: 43824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,Q;
    string S;
    cin >> N >> S >> Q;
    vector<ll> ty(Q), a(Q), b(Q), res;
    vector<char> cq(Q);
    vector<vector<ll>> v(26);
    rep(i,N){
        v[S[i]-'a'].push_back(i);
    }

    rep(i,Q){
        cin >> ty[i] >> a[i];
        if(ty[i] == 1){
            a[i]--;
            cin >> cq[i];
            ll c = S[a[i]] - 'a';
            auto itr = lower_bound(v[c].begin(), v[c].end(), a[i]);
            v[c].erase(itr);
            S[a[i]] = cq[i];
            itr = lower_bound(v[cq[i]-'a'].begin(), v[cq[i]-'a'].end(), a[i]);
            v[cq[i]-'a'].insert(itr, a[i]);
        }else{
            a[i]--;
            cin >> b[i];
            //b[i]--;
            ll ans = 0;
            rep(j,26){
                auto itr = lower_bound(v[j].begin(), v[j].end(), a[i]);
                auto htr = lower_bound(v[j].begin(), v[j].end(), b[i]);
                ans += bool(htr-itr);
                /*if(htr-itr > 0LL){
                    cout <<char(j+'a') <<endl;
                    cout <<ans <<endl;
                }*/
            }
            res.push_back(ans);
        }
    }
    rep(i,res.size()){
        cout << res[i] << endl;
    }

}

Measured memory_bytes: 10424
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main(){
    int N, M; cin >> N >> M;
    vector<int> X(M);
    for(int &x:X)
        cin >> x;
    
    sort(X.begin(), X.end());
    vector<int> V;
    for(int i=1; i<M; i++){
        V.push_back(X[i]-X[i-1]);
    }
    sort(V.begin(), V.end(), greater<int>());
    
    ll ans = 0;
    for(int i=0; i<M-1; i++){
        if(i<N-1) continue;
        ans += V[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int N, M;
int a[100000];
int c[100000];
int b[100001];
int s, t;
int main()
{
	cin >> N;
	M=N/2;
	for(int i=1; i<=M; i++)
	{
		cin >> a[2*i-1] >> c[i];
		if(c[i]==0)
		{
			a[2*i]=1;
		}
		else
		{
			a[2*i]=0;
		}
	}
	if((N%2)!=0)
	{
		cin >> a[N];
	}
	s=1;
	b[0]=0;
	for(int i=1; i<=N-1; i++)
	{
		if(a[i]!=a[i+1])
		{
			b[s]=i;
			s+=1;
		}
		else{}
	}
	b[s]=N;
	if(s<=3)
	{
		t=N;
	}
	else
	{
		t=b[3]-b[0];
		for(int j=0; j+3<=s; j++)
		{
			t=max(t, b[j+3]-b[j]);
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1948
a,b,c,d,e,f = map(int,input().split())
maxa = f//(100*a)

ans = [0,0,0]
for i in range(maxa+1): # iはAの回数
    for j in range((f-100*a*i)//b+1):
        v = 100*a*i + 100*b*j
        if f < v: continue
        for k in range((f-v)//d+1):
            for l in range((f-v-k*d)//c+1,-1,-1):
                s = c*l + d*k
                if v+s > f: continue
                if v/100*e < s: continue
                if v+s == 0: continue
                if ans[0] <= 100*s/(v+s):
                    ans = [100*s/(v+s),v+s,s]
                    break
print(*ans[1:])

Measured memory_bytes: 3064
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;



int main(){
  string s, t; cin >> s >> t;
  int n = s.size(); int cnt = 0;
  rep(i, n){
      if(s[i]!=t[i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3860
#include <stdio.h>

int main() {
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if (A <= C && C <= B) printf("Yes\n");
	else if (B <= C && C <= A) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
int n;
vector<int> G[maxn];
int dfs(int u,int fa) {
    int ret=0,empty=0;
    for (int i=0;i<(int)G[u].size();++i) {
        int v=G[u][i];
        if (v==fa) continue;
        int x=dfs(v,u);
        if (x)
            ret+=x;
        else
            ++empty;
    }
    return ret+max(0,empty-1);
}
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n-1;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int res=1;
    for (int i=0;i<n;++i)
        if ((int)G[i].size()>2) {
            res=max(res,dfs(i,-1));
            break;
        }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 9088
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        if(S.equals("ARC"))System.out.println("ABC");
        else if(S.equals("ABC"))System.out.println("ARC");
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 35592
s = list(input())
t = list(input())

for i in range(len(s)):
    tmp = s[len(s)-1]
    for j in range(len(s))[::-1]:
        s[j] = s[j-1]
    s[0] = tmp
    if s == t:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3060
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t X, N;
  cin >> X >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> hist(103, 0);
  for (int64_t i = 0; i < N; ++i) {
    int64_t p;
    cin >> p;
    ++hist[p];
  }
  int64_t d = INT64_MAX;
  int64_t result;
  for (int64_t i = 0; i <= 101; ++i) {
    if (hist[i] == 0) {
      if (abs(i - X) < d) {
        d = abs(i - X);
        result = i;
      }
    }
  }
  cout << result << endl;
  return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int x, y;
	cin >> x >> y;
	x--; y--;

	int g[] = {0, 1, 0, 2, 0, 2, 0, 0, 2, 0, 2, 0};

	if(g[x] == g[y]){
		puts("Yes");
	}else{
		puts("No");
	}
	
	return 0;
}


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

using namespace std;
int main(){
  vector<int> a;
  for(int i = 0; i <3; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());

  if(a[0]+a[1] == a[2]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
    vector <int> x(5);
    rep(i,5){
        cin >> x[i];
        if(x[i] == 0){
            cout << i+1 <<endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
 
int main () {
    int n, i,A,B, resa, resb;
    while(cin >> n,n){
        resa=0;resb=0;
        for(i=0;i<n;i++){
             cin >> A >> B;
             if(A>B) resa += A+B;
             else if (A<B) resb += A+B;
             else {resa += A; resb +=B;};
        }
    cout << resa << " " << resb << endl;
    }
}

Measured memory_bytes: 1160
N, X, Y = map(int, input().split())
t = [0]*N
for i in range(1, N):
    for j in range(i+1, N+1):
        t[min(j-i, abs(X-i)+1+abs(j-Y))] += 1
for k in range(1, N):
    print (t[k])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
double nDist(vector<vector<int>> a, vector<vector<int>> b, int d){
    double sum = 0;
    double dist = 0.0;
    double tmp = 0;
    for (int i=0; i<d; i++){
        
        tmp = abs(a[i] - b[i]);
        sum += tmp * tmp;
    }
    return sqrt(sum);
}
*/
int main(void){
    int n, d;
    cin >> n >> d;
    
    vector<vector<int>> a(n, vector<int>(d));
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            cin >> a[i][j];
        }
    }
    
    int ans = 0;
    
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int norm = 0;
            for (int k=0; k<d; k++){
                int diff = abs(a[i][k] - a[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for (int k=0; k<=sqrt(norm); k++){
                if (k*k == norm){
                    flag = true;
                }
            }
        if(flag) ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#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()

using namespace std;
using ll = long long;
using ld = long double;

int main() {
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n, x;
    cin >> n;
    map<int, int> m;
    rep(i, n) {
        cin >> x;
        m[x]++;
    }
    vector<pair<int, int>> a;
    for (auto &p : m)
        a.push_back(p);
    if (a.size() == 1 && a[0].first == 0 || a.size() == 3 && (a[0].first ^ a[1].first) == a[2].first && a[0].second == a[1].second && a[0].second == a[2].second || 
            a.size() == 2 && a[0].first == 0 && a[1].second == a[0].second * 2)
        cout  << "Yes";
    else
        cout << "No";
}



Measured memory_bytes: 4988
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#pragma comment(linker, "/STACK: 20000000005")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const ll N = 1e5 + 5, MOD = 1e9 + 7;

string S;
ll n;
ll B[N], C[N];

ll solve (ll x){
    if (x > n)
        return 1;
    if (S[x] == '0')
        return solve (x + 1);
    ll ans1 = solve (x + 1);
    ans1 = ans1 * B[1] % MOD;
    ans1 = (ans1 + C[n - x]) % MOD;
    return ans1;
}

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> S;
    n = (int)S.size();
    S = "#" + S;
    B[0] = 1;
    C[0] = 1;
    for (int i = 1; i <= n; i++){
        B[i] = B[i - 1] * 2 % MOD;
        C[i] = C[i - 1] * 3 % MOD;
    }
    ll ans = solve (1);
    cout << ans << endl;
    return 0;
}


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

int A[100];

int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		A[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(!A[i]){
			cout << char(i+'a') << endl;
			return 0;
		}
	}
	
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
n = gets.chomp.to_i
pillars = gets.chomp.split(" ").map(&:to_i)

max = 0
move_times = 0
(n - 1).times do |i|
    if pillars[i] >= pillars[i + 1]
        move_times += 1
    else
        max = move_times if max < move_times
        move_times = 0
    end
end
max = move_times if max < move_times
puts max


Measured memory_bytes: 9604
#include<iostream>
#include<algorithm>
using namespace std;
signed main(){
  int b[6],a;
  for(int i=0;i<3;i++){
    cin>>b[i];
  }
  for(int i=0;i<3;i++){
    for(int j=i;j<3;j++){
      if(b[i]>b[j]){
	a=b[i];
	b[i]=b[j];
	b[j]=a;
      }
    }
  }
  sort(b,b+3);
  for(int i=0;i<3;i++){
    cout<<b[i];
    if(i<2){
    cout<<" ";
    }
  }
  cout<<"\n";
  return(0);
}




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

int main()
{
    int num;
    char s[105];
    cin >> num  >> s;
    for(int i=0;i<strlen(s);i++){
        if(i<num)
            cout << s[i];
        else
            {
                cout <<"...";
                return 0;
            }
    }
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main()
{
int N,a,b,c,d;
cin >> N;
a=N%10;
b=(N%100-N%10)/10;
c=(N%1000-N%100)/100;
d=(N%10000-N%1000)/1000;
if(a==b && b==c){printf("Yes");}
else{
if(d==b && b==c){printf("Yes");}
else{printf("No");}
}
}

Measured memory_bytes: 256