akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

struct BIT {
  ll num;
  vll bit;

  void set(ll x) {
	num = x;
	bit.resize(x + 1, 0);
  }

  ll sum(ll i) {
	ll ret = 0;
	while (i > 0) {
	  ret += bit[i];
	  i -= i & -i;
	}
	return ret;
  }

  void add(ll i, ll x) {
	while (i <= num) {
	  bit[i] += x;
	  i += i & -i;
	}
  }

};

ll x[MAX * 2];
int main(void) {
  ll le, ri;
  BIT b;
  deque<ll> dq[30];
  cin >> s;
  n = s.length();
  b.set(n + 1);
  FOR(i, 0, n) {
	tmp = s[i] - 'a';
	dq[tmp].push_back(i + 1);
  }

  FOR(i, 0, 30) if (dq[i].size() % 2 == 1) cnt++;
  if (cnt > 1) {
	cout << "-1" << endl;
	return 0;
  }

  if (cnt) flag = true;
  FOR(i, 0, n) {
	tmp = s[i] - 'a';
	if (dq[tmp].empty()) continue;
	if (dq[tmp].size() == 1) {
	  m = dq[tmp].front(); dq[tmp].pop_front();
	  continue;
	}

	le = dq[tmp].front(); dq[tmp].pop_front();
	ri = dq[tmp].back(); dq[tmp].pop_back();
	ans += (n - ri) - (b.sum(n) - b.sum(ri));
	b.add(le, 1); b.add(ri, 1);
	x[le]++;
  }

  cnt = 0;
  FOR(i, 0, 2 * MAX) {
	if (i < m) cnt += x[i];
  }
  if (flag) ans += n / 2 - llabs(cnt);
  cout << ans << endl;

  return 0;
}

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

long long int N, lb, a, z;
bitset<4444> A[7], X, Y, Z;
char s[4444];

template <size_t N>
long long to_modllong(bitset<N> n){
    long long ret = 0;
    for(int i = N; --i >= 0;ret += n[i]){
        ret <<= 1;
        ret %= 998244353;
    }
    return ret;
}

template <typename T>
static inline T gcd(T u, T v){
    int sftu = 0, sftv = 0;
    T t;
    if(u.none()) return v;
    if(v.none()) return u;
    while(!u[0]){
        ++sftu;
        u >>= 1;
    }
    while(!v[0]){
        ++sftv;
        v >>= 1;
    }
    sftu = min(sftu, sftv);
    do{
        while(!v[0])v >>= 1;
        swap(u, v);
        v = v ^ u;
    }while(v.any());
    return u << sftu;
}

int main(){
    scanf("%lld %s", &N, s);
    X = bitset<4444>(s);
    Z = X;
    for(int i = 0; i < N; ++i){
        scanf(" %s", s);
        A[i] = bitset<4444>(s);
    }
    Y = A[0];
    for(int i = 1; i < N; ++i)Y = gcd(A[i], Y);
    for(int i = 4443; i >= 0; --i)if(Y[i] && (lb = i))break;
    for(int i = 4443 - lb; i >= 0; --i){
        if(X[i + lb]){
            X ^= Y << i;
            A[6] ^= Y << i;
        }
    }
    long long d = -1;
    Y = A[6] ^ Z;
    for(int i = 4443; i >= 0; --i)if(Y[i] && (d = i))break;
    cout << (to_modllong(Z >> lb) + (d < 0 || Z[d])) % 998244353 << endl;
    return 0;
}


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

class Pair
{
public:
	string name;
	int value;
};

template<typename T>
class Queue
{
private:
	T* memory;
	int entrance;
	int exit;
	int count;
	int capacity;
public:
	Queue (int capacity)
	{
		this->memory = new T[capacity];
		this->entrance = 0;
		this->exit = 0;
		this->count = 0;
		this->capacity = capacity;
	}
	~Queue ()
	{
		delete[] this->memory;
	}

	void Enqueue (T item)
	{
		memory[entrance] = item;
		count++;

		entrance++;
		if (capacity <= entrance)
		{
			entrance = 0;
		}
	}

	T Dequeue ()
	{
		T returnItem = memory[exit];
		count--;

		exit++;
		if (capacity <= exit)
		{
			exit = 0;
		}

		return returnItem;
	}

	int GetCount ()
	{
		return count;
	}
};


int main ()
{
	int processCount;
	int quantum;

	cin >> processCount >> quantum;

	Queue<Pair> queue (processCount);

	for (int lp = 0; lp < processCount; lp++)
	{
		string name;
		int time;
		cin >> name >> time;
		Pair pair;
		pair.name = name;
		pair.value = time;

		queue.Enqueue (pair);
	}

	int processTime = 0;

	while (queue.GetCount () != 0)
	{
		Pair item = queue.Dequeue ();

		if (quantum <= item.value)
		{
			processTime += quantum;
			item.value -= quantum;
		}
		else
		{
			processTime += item.value;
			item.value = 0;
		}

		if (0 < item.value)
		{
			queue.Enqueue (item);
		}
		else
		{
			cout << item.name << " " << processTime << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 6048
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,d,x,y;
    cin>>n>>d;
    int count=0;
    while(n--){
        cin>>x>>y;
        if(x*x+y*y<=d*d){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, X;
vector<ll> total{1}, patty{1};

ll func(ll n, ll x){
	if(n == 0){
		if(x <= 0) return 0;
		else return 1;
	}else if(x <= 1 + total[n-1]){
		return func(n-1,x-1);
	}else{
		return patty[n-1] + 1 + func(n-1, x-2-total[n-1]);
	}
}

int main(){
	cin >> N >> X;
	for(int i(0);i<N;++i){
		total.push_back(2*total[i]+3);
		patty.push_back(2*patty[i]+1);
	}
	cout << func(N, X) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int H,A;
	scan(H>>A);
	rep1(i,1000000){
		H-=A;
		if(H<=0){
			prin(i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int f(const int d, const int n) {
    return n / d;
}

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

    cout << f(d, R) - f(d, L - 1) << endl;

    return 0;
}


Measured memory_bytes: 3604
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[stdIn.nextInt()-1] = i+1;
		}
		
		for(int i = 0; i < N; i++) {
			System.out.println(A[i]);
		}

	}

}

Measured memory_bytes: 63012
n = int(input())

a = [list(input()) for i in range(n)]

aa = [0,0,0,0,0]

for i in range(n):
    if a[i][0] == "M":
        aa[0] += 1
    elif a[i][0] == "A":
        aa[1] += 1
    elif a[i][0] == "R":
        aa[2] += 1
    elif a[i][0] == "C":
        aa[3] += 1
    elif a[i][0] == "H":
        aa[4] += 1

su = 0

for i in range(3):
    for j in range(1+i,4):
        for k in range(1+j,5):
            su += aa[i] * aa[j] * aa[k]



print(su)

Measured memory_bytes: 20292
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
const int mod=1e9+7;
vector<int>adj[MAX];

int main(){
    long long n;
    cin>>n;
    long long ans=inf;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            //cout<<i<<"\n";
            ans=min(ans, abs(i-(long long)1)+abs(n/i-(long long)1));
        }
    }
    cout<<ans;
}

Measured memory_bytes: 2560
n,k = map(int,input().split())
mod = 10**9+7

s = set()
for i in range(1,int(n**0.5)+1):
    s.add(i)
    s.add(n//i)
l = sorted(list(s))
d = {}
x = len(l)
for i in range(x-1):
    le = n//l[i+1]
    ri = n//l[i]
    d[l[i]] = [ri-le,i]
d[l[-1]] = [1,x-1]

dp = [[0]*(x) for i in range(k+1)]
dp[0][0] = 1
for i in range(k):
    for j in range(x-1):
        dp[i][j+1] += dp[i][j]
        dp[i][j+1] %= mod
    
    for j in range(x):
        s,nj = d[n//l[j]]
        dp[i+1][j] += dp[i][nj]*s
        dp[i+1][j] %= mod
    
print(sum(dp[-1])%mod)
    



Measured memory_bytes: 102660
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long int n,k;
    cin >> n >> k;
    
    long long int ans;
    ans = n%k;
    if(ans > abs(ans-k)) ans = abs(ans-k);
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N, M = input_nums()
    o = (N*N)//2 - (N//2)
    e = (M*M)//2 - (M//2)
    print(o + e)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long a,b,x,c;
  cin >> a >> b >> x;
  c=(b/x);
  if(a != 0){
    c=c-(a-1)/x;
  }else{
    c=c+1;
  }
cout << c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;//xの数
    int x[10000];//元の位置
    int m;//aの数
    int a[10000];//移動させるこまが何番目のものであるか
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf(" %d",&x[i]);
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf(" %d",&a[i]);
        a[i]--;
    }

    for(int i=0;i<m;i++){
        if(x[a[i]]==2019){
            continue;
        }
        if(a[i]+1<n&&x[a[i]+1]==x[a[i]]+1){
		    continue;
        }
		x[a[i]]++;
    }

    for(int i=0;i<n;i++){
        printf("%d\n",x[i]);
    }
    return 0;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll sum[401];
ll dp[401][401];
ll solve(vector<int> &slimes,int i,int j){
	if(i==j)
      return 0;
  	if(dp[i][j]!=-1)
      return dp[i][j];
  	ll cost=LONG_MAX;
  	for(int p=i;p<j;p++)
      cost=min(cost,solve(slimes,i,p)+solve(slimes,p+1,j)+sum[j]-sum[i-1]);
  	return dp[i][j]=cost;
}
int main(){
	int n;
  	cin>>n;
  	vector<int> slimes(n+1);
  	for(int i=1;i<=n;i++)
      	cin>>slimes[i];
  	memset(sum,0,sizeof sum);
  	memset(dp,-1,sizeof dp);
  	for(int i=1;i<=n;i++)
      sum[i]=sum[i-1]+slimes[i];
  	cout<<solve(slimes,1,n);
	}


Measured memory_bytes: 4840
#!/usr/bin/env python3
import sys



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    a = list(map(int,input().split()))
    l = [(a[i]- i-1) for i in range(N)]
    
    l_sorted = sorted(l)
    if N % 2 == 0:
        b_1 = l_sorted[int(N/2)-1]
        b_2 = l_sorted[int(N/2)]
        answer_1 = 0
        answer_2 = 0
        for i in range(N):
            answer_1 += abs(l[i] - b_1)
        for i in range(N):
            answer_2 += abs(l[i] - b_2)

        print(min(answer_1, answer_2))
        exit()
        
    else:
        b = l_sorted[int(N/2)]
        answer = 0
        for i in range(N):
            answer += abs(l[i] - b)

        print(answer)
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 25748
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    for (int i = 0; i < N; ++i)
    {
        cin >> S[i];
    }
    for (int i = 0; i < M; ++i)
    {
        cin >> T[i];
    }

    vector<vector<LLONG>> dp(N + 1, vector<LLONG>(M + 1, 0));
    for (int i = 0; i <= N; ++i)
    {
        dp[i][0] = 1;
    }
    for (int i = 0; i <= M; ++i)
    {
        dp[0][i] = 1;
    }
    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= M; ++j)
        {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            if (S[i - 1] != T[j - 1])
            {
                dp[i][j] -= dp[i - 1][j - 1];
            }
            dp[i][j] = (dp[i][j] + 10 * MOD) % MOD;
        }
    }
    cout << dp[N][M] << endl;
}


Measured memory_bytes: 31616
import java.io.*;
import java.util.*;
import java.math.BigInteger;
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);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
         public void solve(int testNumber, InputReader in, PrintWriter out) {
             int n=in.nextInt();
             int s=0;int a[]=new int[n];
             for(int i=0;i<n;i++)s+=a[i]=in.nextInt();
             BigInteger bi=BigInteger.ONE;
             for(int i=0;i<n;i++){
              bi=bi.or(bi.shiftLeft(a[i]));
             }
             if(s%2==0)s=s/2;else s=s/2+1;//System.out.println(s);
             for(int i=s;;i++){
              if(bi.testBit(i)){out.print(i);return;}
             }
         }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<string> W(N);
  bool ok = true;
  for (int i = 0; i < N; i++) {
    cin >> W.at(i);
    for (int j = 0; j < i; j++) {
      if (W.at(i) == W.at(j)) {
        ok = false;
      }
    }
  } 
  for (int i = 1; i < N; i++) {
    int C = (W.at(i - 1)).size(); 
    if ((W.at(i - 1)).at(C - 1) != (W.at(i)).at(0)) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
    long n, m, x, ans = LONG_MAX;
    cin >> n >> m >> x;
    vector<long> c(n);
    vector<vector<long>> a(n, vector<long>(m));
    rep(i, n) {
        cin >> c.at(i);
        rep(j, m) {
            cin >> a.at(i).at(j);
        }
    }
    rep(i, 2 << n) {
        long temp = 0l;
        vector<long> cur(m, 0);
        rep(j, n) {
            if(1 & (i >> j)) {
                temp += c.at(j);
                rep(k, m) cur.at(k) += a.at(j).at(k);
            }
        }
        bool flag = true;
        rep(j, m) flag &= (cur.at(j) >= x);
        if(flag) ans = min(ans, temp);
    }
    if(ans == LONG_MAX) ans = -1;
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    set<char> t;
    char a, b, c;
    cin >> a >> b >> c;
    t.insert(a), t.insert(b), t.insert(c);

    cout << ((int)t.size() == 3 ? "Yes" : "No") << endl;

}

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

using namespace std;


const int N = 60;

int n0, n1, n;
int a[N][3];
int main() {
    cin >> n0 >> n1 >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) cin >> a[i][j];
    }
    
    for(int i1 = 0; i1 < n; i1++)
        for(int i2 = 0; i2 < n; i2++) {
            int dx = abs(a[i1][0] - a[i2][0]);
            int dy = abs(a[i1][1] - a[i2][1]);
            int dv = abs(a[i1][2] - a[i2][2]);
            if (dv > dx + dy) {
                cout << "No" << endl;
                return 0;
            }
        }
    int ans = 0;
    for(int x = 1; x <= n0; x++)
        for(int y = 1; y <= n1; y++) {
            int res = -10000;
            for(int i = 0; i < n; i++) {
                int dx = abs(x - a[i][0]);
                int dy = abs(y - a[i][1]);
                res = max(res, a[i][2] - dx - dy);
            }
            ans += res;
        }
    cout << ans << endl;
}



Measured memory_bytes: 3116
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DR = { 1, 1, 1, 0, -1, -1, -1, 0 };
	static int[] DC = { -1, 0, 1, 1, 1, 0, -1, -1 };

	public static void main(String[] args) {
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0) break;
			char[][] f = new char[H][];
			for (int i = 0; i < H; ++i) {
				f[i] = sc.next().toCharArray();
			}
			HashSet<String> set = new HashSet<String>();
			String ans = "";
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					for (int k = 0; k < 8; ++k) {
						StringBuilder sb = new StringBuilder();
						sb.append(f[i][j]);
						int cr = i;
						int cc = j;
						boolean[][] visited = new boolean[H][W];
						visited[cr][cc] = true;
						while (true) {
							cr += DR[k];
							cc += DC[k];
							if (cr == -1) cr += H;
							if (cr == H) cr = 0;
							if (cc == -1) cc += W;
							if (cc == W) cc = 0;
							if (visited[cr][cc]) break;
							visited[cr][cc] = true;
							sb.append(f[cr][cc]);
							String str = sb.toString();
							if (set.contains(str)
									&& (str.length() > ans.length() || str.length() == ans.length() && str.compareTo(ans) < 0)) {
								ans = str;
							}
							set.add(str);
						}
					}
				}
			}
			System.out.println(ans.length() == 0 ? 0 : ans);
		}
	}
}

Measured memory_bytes: 210144
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
const int INF = (int)1e9 + 7;
template <class T=int> inline T in() { T x; cin >> x; return (x); }

using pii = pair<int, int>;
list<pair<pii, int>> data;
map<int, bool> deleted;     // default = false;

void init() {
    data.clear();
    data.emplace_back(pii(0, INF), -1);
    deleted.clear();
    deleted[-1] = true;
}

void write() {
    int l = in();       // 書き込むファイルの識別子
    int s = in();       // ファイルを記憶するのに必要とするセクタの数
    for (auto it = data.begin(); it != data.end(); it++) {
        pii& range = it->first;     // half-open
        int& id = (*it).second;
        if (!deleted[id]) continue;
        int h = range.first, t = range.second;
        if (t - h <= s) {
            id = l;
            s -= t - h;
        } else {
            int sep = h + s;
            range = pii(sep, t);
            data.insert(it, make_pair(pii(h, sep), l));
            break;
        }
    }
}

void del() {
    int l = in();       // 削除するファイルの識別子
    deleted[l] = true;
}

int read() {
    int p = in();       // 参照するセクタの番号
    for (auto it = data.begin(); it != data.end(); it++) {
        pii& range = it->first;     // half-open
        int& id = (*it).second;
        int h = range.first, t = range.second;
        if (h <= p && p < t) {
            return deleted[id] ? -1 : id;
        }
    }
    return -1;
}

void print() {
    cout << "----- head ------" << endl;
    for (auto it = data.begin(); it != data.end(); it++) {
        pii& range = it->first; int id = it->second;
        int s = range.first, t = range.second;
        cout << "[" << s << ", " << t << "): " << id << endl;
    }
    cout << "----- tail ------" << endl;
}

int main() {
    int n;
    while (cin >> n, n) {
        init();
        while (n--) {
            char com; cin >> com;
            if (com == 'W') write();
            if (com == 'D') del();
            if (com == 'R') cout << read() << endl;
        }
        //print();
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3432
# -*- coding: utf-8 -*-

X,Y = map(int,input().split())

if Y%2!=0  :
  print("No")
  exit()

#a+b=X
#2a+4b+Y
#2a+2b=2X
#a=(4X-Y)/2
#b=(Y-2X)/2

b=int((Y-2*X)/2)
a=int(X-b)

# if a>=0 and b>=0 -> Yes, else -> No
if a >= 0 and b >= 0 :
  print("Yes")
else:
  print("No")

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

int main(void) {
	int Acoin;
	int Bcoin;
	int toyVal;

	scanf("%d%d%d", &Acoin, &Bcoin, &toyVal);

	if(Acoin + Bcoin >= toyVal){
		printf("Yes");
	} else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int partition(int A[], int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for (int j = p; j < r; j++)
		if (A[j] <= x)
		{
			i++;
			swap(A[i], A[j]);
		}
	swap(A[i + 1], A[r]);
	return i + 1;
}
int main()
{
	int n;
	cin >> n;
	int *A = new int[n];
	for (int i = 0; i < n; i++)
		cin >> A[i];
	int ans = partition(A, 0, n - 1);
	int isf = 0;
	for (int i = 0; i < n; i++)
	{
		if (isf++ > 0)
			cout << " ";
		if (i == ans)
		{
			cout << "[" << A[i] << "]";
			continue;
		}
		cout << A[i];
	}
	cout << endl;
	delete[] A;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n ;
  cin>>n;
  
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end(),greater<ll>());
  
  double half=a[0]/2;
  vector<pair<ll,int>> b;
  rep(i,n-1){
    double x=a[i+1];
    double y=a[0]-a[i+1];
    double X=abs(half-x);
    double Y=abs(half-y);
    if(X<Y) b.push_back(make_pair(X,0));
    else b.push_back(make_pair(Y,1));
  }
  sort(b.begin(),b.end());
  
  if(n==2) cout<<a[0]<<" "<<a[1]<<endl;
  else{
    if(b[0].second==0){
      cout<<a[0]<<" ";
      rep(i,n){
        if(abs(half-a[i])==b[0].first){
          cout<<a[i]<<endl;
          return 0;
        }
      }
    }
    else{
      cout<<a[0]<<" ";
      rep(i,n){
        if(abs(half-(a[0]-a[i]))==b[0].first){
          cout<<a[i]<<endl;
          return 0;
        }
      }
    }
  }
}
  



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;
const int MOD=1000000007;
int n;
vector <int> a,b;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    a.resize(n);
    b.resize(n);
    for (int i=0;i<n;++i)
        cin >> a[i] >> b[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    if (n&1)
    {
        int meda,medb;
        meda = a[n/2];
        medb = b[n/2];
        cout << medb-meda+1;
    }
    else
    {
        int meda,medb;
        meda = (a[n/2 - 1] + a[n/2]);
        medb = (b[n/2 - 1] + b[n/2]);
        cout << (medb-meda) + 1;
    }
    return 0;
}


Measured memory_bytes: 6360
n = int(input())
a = list(map(int, input().split()))
dict = {}
b = [0,0]
c = [0,0]
for i in a:
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
	if dict[i] == 2:
		b.append(i)
	if dict[i] == 4:
		c.append(i)
b.sort(reverse=True)
c.sort(reverse=True)
print (max(b[0] * b[1],c[0]**2))

Measured memory_bytes: 18216
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
        
        int n, t, x; cin >> n >> x >> t;
        int m = n%x;
        int ansr = (n/x) * t;
        
        if(m)
        	ansr+=t;
        cout << ansr << "\n";
        return 0;
}

Measured memory_bytes: 3612
t_life, t_attack, a_life, a_attack = (int(x) for x in input().split())

while t_life > 0 or a_life > 0:
    
    a_life -= t_attack
    if a_life <= 0:
        print('Yes')
        break
        
    t_life -= a_attack
    if t_life <= 0:
        print('No')
        break

Measured memory_bytes: 9160
/**
 * @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 N;
  cin >> N;
  vector<int64_t> T(N);
  int64_t total_time = 0;
  for (int64_t i = 0; i < N; ++i) {
    cin >> T[i];
    total_time += T[i];
  }
  int64_t M;
  cin >> M;
  for (int64_t i = 0; i < M; ++i) {
    int64_t p, x;
    cin >> p >> x;
    cout << (total_time - T[p - 1] + x) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
open Array
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let by, bx = make h false, make w false
let _ =
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do if css.(i).[j] = '#' then (by.(i) <- true; bx.(j) <- true) done done;
  for i = 0 to h - 1 do
    let is_ok = ref false in
    for j = 0 to w - 1 do if by.(i) && bx.(j) then (is_ok := true; print_char css.(i).[j]) done;
    if !is_ok then print_newline () done

Measured memory_bytes: 384
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  vector<int> v(3);
  rep(i, 3) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());

  int ans = 0;

  while (!(v[0] == v[1] && v[0] == v[2])) {
    if (v[1] == v[2]) {
      int dist = v[1] - v[0];
      if (dist % 2 != 0) dist++;
      v[0] += dist;
      ans += dist / 2;
      sort(v.begin(), v.end());
    } else if (v[0] != v[1] && v[1] != v[2]) {
      int dist = v[2] - v[1];
      v[1] += dist;
      v[0] += dist;
      ans += dist;
    } else if (v[0] == v[1]) {
      int dist = v[2] - v[1];
      v[0] += dist;
      v[1] += dist;
      ans += dist;
    }
  }

  cout << ans << endl;
  
  return 0;
}

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

const int MAXN = 200005;

int n, p, d[MAXN];
char s[MAXN];

int main(){
    scanf("%d %d %s", &n, &p, s);
    
    if(p == 2 || p == 5){
        long long res = 0;
        for(int i = 0; i < n; i++){
            if((s[i] - '0') % p == 0){
                res += i + 1;
            }
        }
        printf("%lld\n", res);
    }else{
        d[0]++;
        
        int num = 0, pr = 1;
        long long res = 0;
        
        for(int i = n - 1; i >= 0; i--){
            num = (num + (s[i] - '0') * pr) % p;
          	pr = pr * 10 % p;
          
            res += d[num];
            d[num]++;
        }
        printf("%lld\n", res);
    }
    
    
    return 0;
}

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

int main() {
 int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(B >= A){
cout << C * A << endl;
  }
  else{
    cout << B * C + (A - B) * D << endl;
  }

}


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

int main(void) {
      double n;
      double ans;
      cin >> n;

      if ((int)n % 2) {
            ans = (n + 1) / (2 * n);
      }
      else {
            ans = n / (2 * n);
      }
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
double n,m,x,y;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>x>>y;
	printf("%f ",(double)n*m/2ull);
	if(x==n/2ull&&y==m/2ull)
		puts("1");
	else
		puts("0");
	return 0;
}

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

long long MOD = 1e9 + 7;

long long mul(long long a, long long b) {
    return a * b % MOD;
}

long long fac[100010];

long long pow_mod(long long x, long long n) {
    long long res = 1;
    while (n) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n /= 2;
    }
    return res;
}

long long inv(long long n) {
    return pow_mod(n, MOD - 2);
}

long long binomial(int k, int n) {
    if(n<0 || k<0 || n-k<0) return 0;
    return mul(mul(fac[n], inv(fac[n - k])), inv(fac[k]));
}

int main(int argc, char *argv[])
{
    fac[0] = 1;
    for (int i = 1; i < 100001; i++) {
        fac[i] = mul(fac[i - 1], i);
    }
    int N, K;
    cin >> N >> K;
    vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(begin(a), end(a));
    long long res = 0;
    for (int i = 0; i < N; i++) {
        res = (res - mul(a[i], binomial(K - 1, N - i - 1)) + MOD) % MOD;
        res = (res + mul(a[i], binomial(K - 1, i))) % MOD;
    }
    // for (int i = N - 1; i >= K - 1; i--) {
    //     res = (res + mul(a[i], binomial(K - 1, i))) % MOD;
    // }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>

using namespace std;

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

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

template <typename T>
void ArrayInput(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cin >> *itr;
  }
}
template <typename T>
void ArrayPut(vector<T> &A) {
  for (auto itr = A.begin(); itr != A.end(); ++itr) {
    cout << *itr << " ";
  }
  cout << endl;
}

using Graph = vector<vector<uint32_t>>;
vector<bool> seen;
vector<uint32_t> dis, A_dis, T_dis;

void dfs(Graph &G, uint32_t v) {
  seen[v] = true;

  for (auto itr = G[v].begin(); itr != G[v].end(); ++itr) {
    if (seen[*itr]) continue;
    dis[*itr] = dis[v] + 1;
    dfs(G, *itr);
  }
}

int main() {
  int64_t N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<int64_t> A(N), B;
  ArrayInput(A);
  sort(A.begin(), A.end());
  B = A;
  for (int64_t i = 0; i < (P - 1); ++i) {
    A.pop_back();
  }
  int64_t Border = *(A.end() - 1);
  int64_t Border_num = count(B.begin(), B.end(), Border);
  V -= (P - 1);
  int64_t cnt = 0;
  int64_t sum = 0;
  pair<int64_t, int64_t> sum_p;
  sum_p.first = 0;
  sum_p.second = 0;
  for (auto itr = A.begin(); itr != A.end() && Border > *itr; ++itr) {
    sum_p.first += *itr;
    ++sum_p.second;
  }
  for (auto itr = A.begin(); itr != (A.end() - 1); ++itr) {
    int64_t target = *itr + M, calc = M * ((V - 1) - distance(A.begin(), itr));
    sum_p.first -= *itr;
    --sum_p.second;
    if (target < Border) {
      ++cnt;
      continue;
    }
    calc -= ((target * sum_p.second) - sum_p.first);
    calc -= (target - Border) * Border_num;
    if (calc <= 0)
      break;
    else
      ++cnt;
  }
  cout << N - cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

struct md {
	int y;
	int x;
};

itn main() {
	std::ios::sync_with_stdio(false);

	itn n;

	cin >> n;

	vector<itn> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	RSORT(a, itn);

	vector<itn> score(2, 0);

	REP(i, n) {
		score[i % 2] += a[i];
	}

	cout << score[0] - score[1];

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] task= new int[3];
		int ans=0;


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

		Arrays.sort(task);

		for(int i=0; i<2; i++) {
			ans+=Math.abs(task[i]-task[i+1]);
		}
		System.out.println(ans);
	}
}

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

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

    if (a == b) {
        cout << c << endl;
    } else if (b == c) {
        cout << a << endl;
    } else if (c == a) {
        cout << b << endl;
    }
    return 0;
}


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

int main(){
   int K,A,B;
   cin>> K>> A>>B;
   
    string answer;
   for( int i= A; i <=B ;  i++){

        if(i%K == 0){
            answer = "OK";
            cout<< "OK " <<endl;
            break;
        }
        
    }
if(answer !="OK"){
    cout <<"NG"<< endl;
}

    

}


Measured memory_bytes: 3592
module bbb;import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto N = readln.chomp.to!int;
    auto s = readln.split.map!(to!int);
    auto Ga = s[0];
    auto Sa = s[1];
    auto Ba = s[2];
    s = readln.split.map!(to!int);
    auto Gb = s[0];
    auto Sb = s[1];
    auto Bb = s[2];

    long solve(long n, long g1, long g2, long s1, long s2, long b1, long b2) {
        long[][] X;
        if (g1 < g2) X ~= [g1, g2];
        if (s1 < s2) X ~= [s1, s2];
        if (b1 < b2) X ~= [b1, b2];
        long ans = n;
        if (X.length == 0) return n;
        else if (X.length == 1) return n / X.front[0] * X.front[1] + n % X.front[0];
        else if (X.length == 2) {
            foreach (i; 0..n+1) {
                long j = n - i;
                long tmp = i / X[0][0] * X[0][1] + j / X[1][0] * X[1][1] + i % X[0][0] + j % X[1][0];
                ans = max(ans, tmp);
            }
        }
        else {
            foreach (i; 0..n+1) {
                foreach (j; 0..n-i+1) {
                    long k = n - i - j;
                    if (b1 >= b2) k = 0;
                    //long tmp = i / g1 * g2 + j / s1 * s2 + k / b1 * b2 + i % g1 + j % s1 + k % b1;
                    long tmp = i / X[0][0] * X[0][1] + j / X[1][0] * X[1][1] + k / X[2][0] * X[2][1] + i % X[0][0] + j % X[1][0] + k % X[2][0];
                    ans = max(ans, tmp);
                }
            }
        }
        return ans;
    }

    auto M = solve(N, Ga, Gb, Sa, Sb, Ba, Bb);
    auto L = solve(M, Gb, Ga, Sb, Sa, Bb, Ba);
    L.writeln;


}



Measured memory_bytes: 256
a=int(input())
b=0
d=0
e=0
f=0
g=0
while b<a:
    c=input()
    if c=='AC':
        d=d+1
    if c=='WA':
        e=e+1
    if c=='TLE':
        f=f+1
    if c=='RE':
        g=g+1
    b=b+1
print('AC','x',d)
print('WA','x',e)
print('TLE','x',f)
print('RE','x',g)


Measured memory_bytes: 9204
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
string s;
string t;

bool judge(int i){
    for(int j=0;j<t.length();j++){
        if(s[i+j]!=t[j] && s[i+j]!='?') return false;
    }
    return true;
}

int main(){
    cin>>s>>t;
    bool f=true;
    for(int i=s.length()-t.length();i>=0;i--){
        if(judge(i)){
            f=false;
            for(int j=0;j<t.length();j++){
                s[i+j]=t[j];
            }
            break;
        }
    }
    if(f){
        cout<<"UNRESTORABLE"<<endl;
    }else{
        for(int i=0;i<s.length();i++){
            if(s[i]=='?') s[i]='a';
        }
        cout<<s<<endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <array>

int main(int argc, char *argv[]){
    constexpr int MAX_N = 2000;
    int N;
    std::cin >> N;
    std::array<int, MAX_N> L;
    for(int i=0; i<N; ++i){
        std::cin >> L[i];
    }
    std::sort(L.begin(),L.begin()+N);

    int sum=0;
    for(auto i = L.begin(); i<L.begin()+N; ++i){
        for(auto j = std::upper_bound(L.begin(),i,((*i)>>1)); j<i; ++j){
            auto k = std::upper_bound(L.begin(),j,(*i)-(*j));
            sum += j-k;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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 (b<a) { a=b; return 1; } return 0; }

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);
	ll lc = (a/g) * b;
	return lc;
}

int MAXN=100;
int MAXK=10;

int main(){
    ios::sync_with_stdio(false);
    int n,k,d;
    cin >> n >> k;
    int a[MAXN+5];
    set<int> s;
    rep(i,k){
        cin >> d;
        rep(j,d){
            cin >> a[j];
            s.insert(a[j]);
        }
    }
    cout << n-s.size() << endl;
    return 0;
}

Measured memory_bytes: 3656
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    H, W = map(int, input().split())
    S = ['']* H
    for i in range(H):
        S[i] = input()
    delta = [1, -1]
    ans = 'Yes'
    for i in range(H):
        for j in range(W):
            if S[i][j] == '#':
                bl = False
                for d in delta:
                    if 0<=i+d<H and S[i+d][j]=='#':
                        bl = True
                    if 0<=j+d<W and S[i][j+d]=='#':
                        bl = True
                if bl == False:
                    ans = 'No'
    print(ans)







if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();

        int res=1000;

        for(int i=0; i<S.length-T.length+1; i++){
            int count=T.length;
            for(int j=0; j<T.length; j++){
                if(S[i+j]==T[j]){
                    count--;
                }
            }
            res = Math.min(res,count);
        }
        
        System.out.println(res);
}

}



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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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 (b<a) { a=b; return 1; } return 0; }





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

  int resi = N % 1000;
  if(resi == 0){
    cout << 0 << endl;
    return 0;
  }
  cout << 1000 - resi << endl;

  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3632
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict

def solve():
    cnt = defaultdict(int)
    for i in range(3):
        a, b = input().split()
        cnt[a] += 1
        cnt[b] += 1
    ok = len(cnt.keys()) == 4
    one, two = 0, 0
    for v in cnt.values():
        if v == 1:
            one += 1
        if v == 2:
            two += 1
    ok = ok and (one == 2 and two == 2)
    print("YES" if ok else "NO")
    

if __name__=="__main__":
    solve()


Measured memory_bytes: 3572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k[] = new int[n];
            int dishes[] = new int[m];
            for (int i = 0; i < n; i++) {
                k[i] = Integer.parseInt(in.next());
                for (int j = 0; j < k[i]; j++) {
                    dishes[Integer.parseInt(in.next()) - 1]++;
                }
            }
            int ans = 0;
            for (int i = 0; i < m; i++) {
                if (dishes[i] == n) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define int long long int
signed main(void)
{
    int N;
    cin >> N;
    vector<int> a(3*N);
    priority_queue<int, vector<int>, greater<int> > min_a;
    priority_queue<int> max_a;

    for( int i = 0; i < 3*N; i++){
        cin >> a[i];
    }
    int ans;

    int max_sum[3*N+1] = {0};
    int min_sum[3*N+1] = {0};
    int tmp_max = 0;
    int tmp_min = 0;

    for( int i = 0; i < N; i++){
        tmp_min += a[i];
        min_a.push(a[i]);
    }
    for( int i = 2*N; i < 3*N; i++){
        tmp_max += a[i];
        max_a.push(a[i]);
    }

    ans = tmp_min - tmp_max; 
    min_sum[N-1] = tmp_min;
    max_sum[2*N] = tmp_max;

    for( int i = N; i < 2*N; i++){
        min_a.push(a[i]);
        tmp_min += a[i];
        tmp_min -= min_a.top();
        min_sum[i] = tmp_min;
        min_a.pop();
    }

    for( int i = 2*N-1; i >= N; i--){
        max_a.push(a[i]);
        tmp_max += a[i];
        tmp_max -= max_a.top();
        max_sum[i] = tmp_max;
        max_a.pop();
    }

    for( int i = N-1; i < 2*N; i++){
        //cout << min_sum[i] << "," <<max_sum[i+1] << endl;
        if( ans < min_sum[i] - max_sum[i+1] ){
            ans =  min_sum[i] - max_sum[i+1];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using ll = long long;
const ll MOD = 1000000007;
#define rep(i,n) for (ll i=0; i < (n); i++)
using namespace std;
int get_gcd(int a, int b) {
  while(1) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

// 組み合わせnCrをMODで割った時の余り
ll c[2001][2001];

int main () {
  ll n, k;
  cin >> n >> k;

  //組み合わせnCr (0<=n<=2000, 0<=r<=n)を動的計画法で計算する
  //まずc[i][i] = 1, c[i][0] = 1とする。
  //次にc[i][j]について、c[i][j] = c[i-1][j] + c[i-1][j-1]を用いて算出する。
  for (int i = 0; i <= 2000; i++) {
    c[i][i] = 1;
    c[i][0] = 1;
  }
  for (int i = 2; i <= 2000; i++) {
    for (int j = 1; j < i; j++) {
      c[i][j] = (c[i-1][j] + c[i-1][j-1]) % MOD;
    }
  }

  //各i (1<=i<=k)について、解はc[k-1][i-1]*c[n-k+1][i]
  for (int i=1; i<=k; i++) {
    cout << (c[k-1][i-1]*c[n-k+1][i])%MOD << endl;
  }

  return 0;
}


Measured memory_bytes: 30080
import math._

object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt

    var ans = 100000
    for (i <- 1 to n) {
      ans = (ans * 1.05).toInt
      if (ans % 1000 > 0)
        ans += 1000

      ans = ans / 1000 * 1000
    }
    println(ans)
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e2) + 5;
const int MAX_A = int(15e6);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n;
    map<int, int> mp[2];
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        mp[i%2][a]++;
    }
    int s[2] = {n/2,n/2}, t = IINF, use = 0;
    REP(k,2){
        for(auto it: mp[k]){
            if(s[k]>n/2-it.second){
                if(k==0)use = it.first;
                else if(use == it.first) continue;
                s[k] = n/2-it.second;
            }
        }
    }
    t = s[0] + s[1];
    s[0] = s[1] = n/2;
    REPR(k,1){
        for(auto it: mp[k]){
            if(s[k]>n/2-it.second){
                if(k==1)use = it.first;
                else if(use == it.first) continue;
                s[k] = n/2-it.second;
            }
        }
    }
    t = min(t, s[0]+s[1]);
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 4992