akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ 1e9 + 7 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-7;
long double pi = acosl(-1);
ifstream in("input.txt");
ofstream out("output.txt");

void solve()
{
	int n;
	cin >> n;
	vector<long long> a (n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	set<pair<pair<int, int>, int>> c;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			for (int k = j + 1; k < n; k++)
			{
				if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k] || a[j] == a[k]) continue;
				if (a[i] < a[j] + a[k] && a[j] < a[i] + a[k] && a[k] < a[i] + a[j])
				{
					ans++;
				}
			}
		}
	}
	cout << ans;
}

int main()
{
	cout << setprecision(2) << fixed;
	cin.tie();
	cout.tie();
	//freopen("input.txt", "r", stdin);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
	}
	gg;
}

Measured memory_bytes: 3636
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<deque>
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,n) for(lld i=a;i<n;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,n) for(lld i=n-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector 
#define p(x,y)  pair<x,y> 
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<": "; }

//prime[i]==1 if it is prime 
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[j]==1)
           prime[j]=i; 
      }
}

lld gcd(lld a,lld b)
{
    if(a==0)
     return b; 
    return gcd(b%a,a); 
}

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/ 
void bfs(lld s,v<lld> g[],lld n)
{ 
   bool vis[n]; 
   rec(i,n) 
    vis[i]=false; 
    
   vis[s]=true; 
   deque<lld> q; 
   q.pb(s); 
   
   while(!q.empty()) 
   {  
      s=q.front(); 
     q.pop_front(); 
      
     for(lld i=0;i<g[s].size();i++) 
      {  
        if(!vis[g[s][i]])
         { vis[g[s][i]]=true; 
            q.pb(g[s][i]); 
         }
      }
   }
}

void dfs(lld u,v<lld> g[],bool *vis)
{ 

   vis[u]=true; 
   for(lld i=0;i<g[u].size();i++) 
     if(!vis[g[u][i]])
          dfs(g[u][i],g,vis); 
       
}
void contest(lld t); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld T=1; 
  
    rec(t,T) 
    {
      contest(t); 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest(lld t)
{ 
  lld n; 
  cin>>n; 
  cout<<(1-n)<<endl; 
}

Measured memory_bytes: 3648
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;

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

    public static void main(String[] args) {
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        Integer[] p = new Integer[A];
        Integer[] q = new Integer[B];
        Integer[] r = new Integer[C];
        for (int i = 0; i < A; i++) p[i] = sc.nextInt();
        for (int i = 0; i < B; i++) q[i] = sc.nextInt();
        for (int i = 0; i < C; i++) r[i] = sc.nextInt();

        Arrays.sort(p, Collections.reverseOrder());
        Arrays.sort(q, Collections.reverseOrder());
        Arrays.sort(r, Collections.reverseOrder());
        Integer[] eat = new Integer[X + Y];
        for (int i = 0, j = 0, k = 0, xy = X + Y; i + j + k < xy;) {
            int a = 0, b = 0, c = 0;
            if (i != X) a = p[i];
            if (j != Y) b = q[j];
            if (k != C) c = r[k];
            if (a >= b && a >= c) eat[i + j + k] = p[i++];
            else if (b >= a && b >= c) eat[i + j + k] = q[j++];
            else eat[i + j + k] = r[k++];
        }
        long ans = 0;
        for (Integer i : eat) ans += i;
        System.out.println(ans);
    }
}


Measured memory_bytes: 102500
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d = new int[N];
        for(int i=0;i<N;i++){
            d[i] = sc.nextInt();
        }

        int sum = 0;
        int tmp = 0;
        for(int i=0;i<d.length;i++) {
            for(int j=i+1;j<d.length;j++){
                tmp = d[i] * d[j];
                sum += tmp;
            }
        }

        System.out.println(sum);
        
    }
}

Measured memory_bytes: 21844
loop {
	n, m = gets.split.map(&:to_i)
	break if n == 0 && m == 0
	a = [0]
	if n != 0
		a += gets.split.map(&:to_i)
	end
	if m != 0
		a += gets.split.map(&:to_i)
	end
	a.sort!
	b = []
	for i in 0...(n+m)
		b += [a[i+1] - a[i]]
	end
	p b.max
}

Measured memory_bytes: 116556
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}


int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define NUM_MAX 200000
#define BUF_SIZE (NUM_MAX+50)
#define PRIME_MAX 10000

int chr_to_digit(char ch) {
    return ch - '0';
}

int main(void) {
    int num, divisor;
    get_int2(&num, &divisor);

    static char str[BUF_SIZE];
    static int mod_map[PRIME_MAX];
    get_str(str, BUF_SIZE);
    int i;

    int64_t ans = 0;
    if(divisor == 2 || divisor == 5) {
        for(i = num-1; i >= 0; i--) {
            if(!(chr_to_digit(str[i])%divisor)) {
                ans += (i+1);
            }
        }
        goto finish;
    }
    
    // divisor has nothing to do with 10**n.
    int sum = 0;
    int power10 = 1;
    for(i = num-1; i >= 0; i--) {
        sum = (chr_to_digit(str[i])*power10+sum)%divisor;
        power10 = (power10*10)%divisor;
        mod_map[sum]++;
    }
    int offset = 0;
    ans += mod_map[offset];
#ifdef DEBUG
    printf("ans: %lld\n", ans);
#endif
    power10 = 1;
    for(i = num-1; i >= 0; i--) {
        offset = (chr_to_digit(str[i])*power10+offset)%divisor;
        power10 = (power10*10)%divisor;
        mod_map[offset]--;
        ans += mod_map[offset];
#ifdef DEBUG
        printf("ans: %d\n", mod_map[offset]);
#endif
    }
finish:
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-13 14:06:02
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

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

    LL ans = N;
    for (LL i = 1; i <= (LL)sqrt(N); i++) {
        if (N % i == 0) {
            LL pro = i + N/i - 2;
            if (ans > pro) ans = pro;
        }
    }

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long n;
int sum,sw,w;
int dsm(long long a){
	int sum=0;
	while(a){
		sum+=a%10;
		if(a<10) sw=a;
		a/=10,w++;
	}
	return sum;
}
int main(){
	scanf("%lld",&n);
	sum=dsm(n);
	printf("%d\n",max(sum,sw+w*9-10));
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << 0 << endl;
  } else {
    ll cand1 = (a / 2 + 1) * b * c - (a / 2) * b * c;
    ll cand2 = a * (b / 2 + 1) * c - a * (b / 2) * c;
    ll cand3 = (c / 2 + 1) * b * a - (c / 2) * b * a;
    cout << min({cand1, cand2, cand3}) << endl;
  }
  return 0;
}

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

int main()

{
        string s;
        cin >> s;

        int len = s.length();

        int c = 0;
        for (int i = 0; i < len; ++i) {
                if (s[i] == '1') {
                        c++;
                }
        }
        cout << c << endl;








}


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

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

  cout << N / 2 + max(0, N % 2) << endl;
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    int ans = (a+b)*h/2;
    cout << ans << endl;
    return 0;
}

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

int main() {
  vector<int> a(3);
  for (int i=0; i<3; ++i) cin >> a[i];
  sort(a.rbegin(), a.rend());
  cout << a[0]*10+a[1]+a[2] << endl;
  return 0;
}

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

void makeVec(vector<int> &vec){
    long long len = vec.size();
    for(int i = 0; i < len; i++){
        cin >> vec[i];
    }
    return;
} 

int main(){
    long long h, n;
    cin >> h >> n;
    vector<int> a(n);
    makeVec(a);
    int sum = accumulate(a.begin(), a.end(), 0);
    string ans;
    if(sum >= h) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;

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

char field[10][10];

int main()
{
  while (true) {
    for (int i = 0; i < 10; i++) {
      fill(field[i], &field[i][10], '0');
    }
    if (scanf("%c ", &field[1][1]) != 1) {break;}
    for (int i = 2; i < 9; i++) {
      scanf("%c ", &field[1][i]);
    }
    for (int i = 2; i < 9; i++) {
      for (int j = 1; j < 9; j++) {
	scanf("%c ", &field[i][j]);
      }
    }
    
    /*for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
	printf("%c ", field[i][j]);
      }
      printf("\n");
      }*/

    for (int i = 1; i <= 8; i++) {
      for (int j = 1; j <= 8; j++) {
	if (field[i][j] == '1') {
	  int c = 0;
	  for (c = 0; c < 7; c++) {
	    for (int k = 0; k < 3; k++) {
	      if (field[i - dy[c][k]][j + dx[c][k]] == '0') {goto next;}
	    }
	    printf("%c\n", 'A' + c);
	    goto end;
	  next:;
	  }
	}
      }
    }
  end:;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
	int n;
	double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
	for(int i = 0; i < n; i++) scanf("%lf",&y[i]);

	for(int i = 0; i < n; i++){
		p_1 += abs(x[i] - y[i]);
		p_2 += (x[i] - y[i])*(x[i] - y[i]);
		p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
		p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
 	}
	printf("%.6lf\n",p_1);
	printf("%.6lf\n",sqrt(p_2));
	printf("%.6f\n",cbrt(p_3));
	printf("%.6lf\n",p_infinity);

}






Measured memory_bytes: 2956
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		char ch[]=in.next().toCharArray();
		char af[] = new char[ch.length];
		char p = 3;
		for(int i=0; i<ch.length; i++)
		{
			if(ch[i]=='A')
				af[i]='X';
			else if(ch[i]=='B')
				af[i]='Y';
			else if(ch[i]=='C')
				af[i]='Z';
			else
			af[i]= (char)(ch[i]-p);	
		}
		System.out.println(af);
	}
}

Measured memory_bytes: 12000
while gets
n=$_.to_i;d=(0...n).to_a
gets.split.map(&:to_i).each{|e|d=d[n/2..-1].each_slice(e).to_a.zip(d[0...n/2].each_slice(e).to_a).flatten[0...n]}
p d[n-1]
end

Measured memory_bytes: 5948
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int ten[10];
  int a1,a2;
  REP(i,10){
    cin>>ten[i];
  }
  sort(ten,ten+10);
  a1=ten[9]+ten[8]+ten[7];
  REP(i,10){
    cin>>ten[i];
  }
  sort(ten,ten+10);
  a2=ten[9]+ten[8]+ten[7];
  printf("%d %d\n",a1,a2);
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  char chino[5];
  int i;
  scanf("%s", chino);
  for(i=0;chino[i]!='\0';i++);
  if(i==2) printf("%s\n", chino);
  if(i==3) {
    for(i=2;i>=0;i--) printf("%c", chino[i]);
    printf("\n");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

int h, w;
char g[1005][1005];
int d[1005][1005];
queue<pii> q;

int dr[] = {1, 0, -1, 0};
int dc[] = {0, 1, 0, -1};
inline bool ins(int r, int c){
	return 1 <= r && r <= h && 1 <= c && c <= w;
}
int main(){
	scanf("%d %d", &h, &w);
	for (int i = 1; i <= h; i++)
		scanf("%s", g[i] + 1);
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++)
		d[i][j] = 5000 * (g[i][j] == '.' ? 1 : (q.emplace(i,j), 0));
	while (!q.empty()){
		pii u = q.front(); q.pop();
		for (int i = 0; i < 4; i++){
			int r = u.fi + dr[i], c = u.se + dc[i];
			if (ins(r, c) && d[r][c] > d[u.fi][u.se] + 1){
				d[r][c] = d[u.fi][u.se] + 1;
				q.emplace(r, c);
			}
		}
	}
	int mx = 0;
	for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++)
		mx = max(mx, d[i][j]);
	printf("%d\n", mx);
	return 0;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> times(n);
    for(int i=0;i<n;i++){
        cin >> times.at(i);
    }
    int m;
    cin >> m;
    vector<int> ps(m), xs(m);
    for(int l=0;l<m;l++){
        cin >> ps.at(l) >> xs.at(l);
    }
    for(int j=0;j<m;j++){
        int sum =0;
        for(int k=0;k<n;k++){
            if(k+1==ps.at(j)){
                sum += xs.at(j);
            }
            else sum += times.at(k);
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


R = ni()
print(float(R)*3.141592653 * 2 )


Measured memory_bytes: 9180
<?php
  
$nk = explode(' ', trim(fgets(STDIN)));
$n = $nk[0];
$k = $nk[1];
$h = explode(' ', trim(fgets(STDIN)));

$c = 0;
for($i=0; $i<$n; $i++){
  if ($h[$i] >= $k) $c++;
}

echo $c;

?>

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b < 10) {
		cout << a + b << endl;
	}
	else {
		cout << "error" << endl;
	}
	return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<vector<int>> l(n+1);  
  if(k > (n-1)*(n-2)/2){
    cout << -1;
  }else{
    int c = (n-1)*(n-2)/2 -k;
    //cout << c << endl;
    int r = 0;
    int m =0;
    for(int i = 2;i<n+1;i++){
      l[1].push_back(i);
      m++;
    }
    
    for(int i = 2;i<n+1;i++){
      for(int j =i+1;j<n+1;j++){
        if(c==0){break;}
        l[i].push_back(j);
        r++;
        m++;
        if(r == c){break;}
      }
      if(r == c){break;}
    }
    cout << m << endl;
    //cout << m << endl
    for(int i = 1;i<n+1;i++){
      for(int j = 0;j<l[i].size();j++){
        cout << i << " " << l[i][j] << endl;
      }
    }
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int ans=0;
    rep(i,1,(n+1)/2){
        int j=1,cnt=0;
        while((2*i-1)/j>=j){
            cnt += ((2*i-1)%j==0?2:0);
            j++;
        }
        if(cnt==8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
t_list = []
diff_list = []
for i in h:
    i = t - i * 0.006
    t_list.append(i)
for j in t_list:
    j = abs(j -a)
    diff_list.append(j)
print(diff_list.index(min(diff_list)) + 1)

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

int l1,l2,ans=0x3f3f3f3f,zz;
char a[2005],b[2005];

int main(){
	
	scanf("%s" , a + 1);
	scanf("%s" , b + 1);
	l1 = strlen(a + 1);
	l2 = strlen(b + 1);
	for(int i = 1 ; i + l2 - 1 <= l1 ; i++){
		
		zz = 0;
		for(int k = 1 ; k <= l2 ; k++){
			if(a[i + k - 1] != b[k])zz++;
		}
		ans = min(ans , zz);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int n,k;
vector<int> arr;
int dp[100001][2];
int solve(int left,int mover){
    
    if(dp[left][mover]!=-1) return dp[left][mover];
    
    if(mover==0){
        for(int i=0;i<n;i++){
            if(arr[i]==left)
                return dp[left][mover] = 0;
            if(left>arr[i]){
            if(solve(left-arr[i],1)==0)
                return dp[left][mover]=0;}
        }
        return dp[left][mover]=1;
    }
    else {
        for(int i=0;i<n;i++){
            if(arr[i]==left)
                return dp[left][mover] = 1;
            if(left>arr[i]){
            if(solve(left-arr[i],0)==1)
                return dp[left][mover]=1;}
        }
        return dp[left][mover]=0;
    }
    
    return 1;
    
}

int main() {
	cin>>n>>k;
	arr.resize(n);
	//memset(dp,-1,sizeof dp);
	for(int i=0;i<=k;i++){
	    dp[i][0]=dp[i][1] = -1;
	}
	for(int i=0;i<n;i++) cin>>arr[i];
	
	if(solve(k,0)==0) cout<<"First";
	else cout<<"Second";
	
	return 0;
}

Measured memory_bytes: 5760
(defparameter n (read))
(defparameter a (read))
(defparameter b (read))
(defparameter c (read))
(defparameter d (read))
(defparameter e (read))

(defun f (a b c d e n)
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (labels ((rec (one two three four five six acc)
             (if (= n six)
                 acc
                 (let ((one* (min one a))
                       (two* (min two b))
                       (three* (min three c))
                       (four* (min four d))
                       (five* (min five e)))
                   (rec (+ one (- one*))
                        (+ two one* (- two*))
                        (+ three two* (- three*))
                        (+ four three* (- four*))
                        (+ five four* (- five*))
                        (+ six five*)
                        (1+ acc))))))
    (rec n 0 0 0 0 0 0)))

(defun f (a b c d e n)
  (let ((min-abcde (min a b c d e)))
    (+ 4 (ceiling n min-abcde))))

(princ (f a b c d e n))


Measured memory_bytes: 17760
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll k,a[2];cin >> k >> a[0] >> a[1];
	
	if(a[0] >= k)
	{
		cout << 1 << endl;
		return 0;
	}
	
	if(a[0] <= a[1])
	{
		cout << -1 << endl;
		return 0;
	}
	
	
	ll ans = 0;
	if(k / (a[0] - a[1]) > 100000000)
	{
		ans = (2 * ( k / ( a[0] - a[1] ))) - 10;
		k -= (a[0] - a[1]) * (ans / 2);
	}
	
	a[1] = -a[1];
	
	for(int i = 0;;i = (i+1)%2)
	{
		if(k <= 0)
		{
			cout << ans << endl;
			return 0;
		}
		k -= a[i];
		ans++;
	}
		
	
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
L=[list(map(int,input().split()))for i in range(M)]
r=N
l=0
for i in range(M):
    l=max(l,L[i][0])
    r=min(r,L[i][1])
if r-l+1<0:
    print(0)
else:
    print(r-l+1)

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

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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int m=read<int>(), n=read<int>();
	int a[m], b[n];
	rep(i, m) a[i]=read<int>();
	rep(i, n) b[i]=read<int>();
	
	int ans= 0;
	
	//Bluno Start
	rep(i, n){
		int index = 0;
		//Bluno End+1
		int j;
		for(j = i;j<n;j++){
			while(b[j]!=a[index++]) if(index>=m) goto nextLoop;
			// printf("(%d, %d)\n", j, index);
		}
nextLoop:
		ans=max(ans, j-i);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
using namespace std;
string S, T, U; int a[4], b[4], h, v;
int main() {
	while (cin >> S >> T) {
		h = 0; v = 0;
		if (S == "0") { break; }
		for (int i = 0; i < 4; i++) {
			U = S[i];
			U += "0";
			a[i] = stoi(U) / 10;
		}
		for (int i = 0; i < 4; i++) {
			U = T[i];
			U += "0";
			b[i] = stoi(U) / 10;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j) { h++; }
					else { v++; }
				}
			}
		}
		cout << h << ' ' << v << endl;
	}
}

Measured memory_bytes: 3160
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int b[2][100000];
char c[2][100000];
int partition(int p,int r){
  int x=b[0][r],j,i=p-1;

  for(j=p;j<r;j++){
    if(b[0][j]<=x){
      i=i+1;
      swap(b[0][i],b[0][j]);
      swap(c[0][i],c[0][j]);
    }
  }
  
  swap(b[0][i+1],b[0][r]);
  swap(c[0][i+1],c[0][r]);
  return i+1;
}
void quicksort(int p,int r){
  if(p<r){
    int q=partition(p,r);
    quicksort(p,q-1);
    quicksort(q+1,r);
  }
}
/*
void bubblesort(int n){
  bool flag=1;
  while(flag){
    flag=0;
    for(int j=n-1;j>0;j--){
      if(b[1][j]<b[1][j-1]){
	swap(b[1][j],b[1][j-1]);
	swap(c[1][j],c[1][j-1]);
	flag=1;
      }
    }
  }

}
*/

void merge(int left,int mid ,int right){
  int n1=mid-left,n2=right-mid;
  int l[n1+1],r[n2+1];
  char cl[n1+1],cr[n2+1];
    for(int i=0;i<n1;i++){
    l[i]=b[1][left+i];
    cl[i]=c[1][left+i];
    }
  for(int i=0;i<n2;i++){
    r[i]=b[1][mid+i];
    cr[i]=c[1][mid+i];
  }
  l[n1]=r[n2]=1+pow(10,9);
  int i=0,j=0,k;
  for(k=left;k<right;k++){
    if(l[i]<=r[j]){
      b[1][k]=l[i];
      c[1][k]=cl[i];
      i++;

    }
    else{
      b[1][k]=r[j];
      c[1][k]=cr[j];
      j++;

    }
  }
}
void mergesort(int left,int right){
  int mid;
  if(left+1<right){
    mid = (left +right)/2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}



void comp(int n){
  bool jud=1;
  for(int i=0;i<n;i++){
    if(c[0][i]!=c[1][i]){
      jud=0;
      break;
    }
  }
  if(!jud)cout<<"Not stable"<<endl;
  else cout<<"Stable"<<endl;
}




int main(){
  int n,i;
  cin>>n;
  for(i=0;i<n;i++)cin>>c[0][i]>>b[0][i];
  for(i=0;i<n;i++){
    c[1][i]=c[0][i];
    b[1][i]=b[0][i];
  }
  quicksort(0,n-1);
  //bubblesort(n);
  mergesort(0,n);
  comp(n);
  for(i=0;i<n;i++)cout<<c[0][i]<<" "<<b[0][i]<<endl;

  return 0;
}



Measured memory_bytes: 4540
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n,m;
int arr[100001];
string s;
bool pal(string x){
    n=x.size();
    for (int i=0;i<n;i++){
        if (x[i]!=x[n-i-1]){
            //cout<<x<<'\n';
            return false;
        }
    }
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    if (!pal(s)){
        cout<<"No";
        return 0;
    }
    string x;
    m=s.size();
    for (int i=0;i<(m-1)/2;i++){
        x.pb(s[i]);
    }
    if (!pal(x)){
        cout<<"No";
        return 0;
    }
    x="";
    for (int i=(m+3)/2-1;i<m;i++){
        x.pb(s[i]);
    }
    if (!pal(x)){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
    /*
    for (int i=1;i<=n;i++){
        cin>>arr[i];
    }
    */
    cout<<(n*(n-1))/2+(m*(m-1))/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int n; cin >> n;
    map<int, int> s;
    int max = 1;

    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        s[tmp]++;
        if(s[tmp]>max){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;

}


Measured memory_bytes: 9600
N = input()
a = [int(x) for x in input().split()]

b = {}

for i in a:
    if i in b:
        b[i] += 1
    else:
        b[i] = 1

ans = 0
for k,v in b.items():
    if v > k:
        ans += ( v - k )
    elif v < k:
        ans += v

print(ans)

Measured memory_bytes: 17780
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;



int main(){
    long long int n,m,a,b,ans=0;
    cin>>n>>m;
    vector<long long int>h(100000);
    vector<long long int>y(100000);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(h[a-1]>h[b-1]){
            y[b-1]=1;
        }
        else if(h[a-1]<h[b-1]){
            y[a-1]=1;
        }
        else{
            y[b-1]=1;
            y[a-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        //cout<<y[i]<<endl;
        if(y[i]==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    int n;
    cin >> n;
    if(n % 1000 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1000 - n % 1000 << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int N;

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

  ll num = 0;
  for (int i = 1; i <= 2 * N; i++) {
    if ((2 * N) % i == 0 && (2 * N) / i == (i - 1)) {
      num = i;
      break;
    }
  }

  if (num == 0) {
    cout << "No" << endl;
    return 0;
  }

  vector<vector<int>> ans(num, vector<int>(num - 1, 0));
  P posR = make_pair(0, 0);
  P posC = make_pair(1, 0);
  for (int i = 1; i <= N; i++) {
    ans[posR.first][posR.second] = i;
    ans[posC.first][posC.second] = i;
    if (posR.first == posC.first - 1 && posR.second == posC.second) {
      posR = make_pair(0, posR.second + 1);
      posC = make_pair(posC.first + 1, 0);
    } else {
      posR = make_pair(posR.first + 1, posR.second);
      posC = make_pair(posC.first, posC.second + 1);
    }
  }

  cout << "Yes" << endl;
  cout << ans.size() << endl;
  rep(i, ans.size()) {
    cout << ans[i].size();
    rep(j, ans[i].size()) { cout << " " << ans[i][j]; }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3880
#include<iostream>
#include<queue>
using namespace std;
int n,u,k,v,**M;

void bfs(int src)
{
  int D[100];
  for(int i=0;i<100;i++)
    D[i]=-1;
  queue<int>Q;
  Q.push(src);
  D[src]=0;
  while(!Q.empty())
    {
      int cur=Q.front();
      Q.pop();
     // cout<<cur+1<<' '<<D[cur]<<endl;
       for(int dst=0;dst<n;dst++)
	{
	  if(M[cur][dst]==1&&D[dst]==-1)
	    {
	      D[dst]=D[cur]+1;
	      Q.push(dst);
	    }
    }
    }
    for(int i=0;i<n;i++)
        cout<<i+1<<' '<<D[i]<<endl;
}

int main()
{
  //int n,u,k,v,**M;
  cin>>n;
  M=new int*[n];
  for(int i=0;i<n;i++)
    {
      M[i]=new int[n];
      for(int j=0;j<n;j++)
	M[i][j]=0;
    }
  int count=0;
  while(count<n)
    {
      count++;
      cin>>u>>k;
      for(int i=0;i<k;i++)
	{
	  cin>>v;
	  M[u-1][v-1]=1;
	}
    }
    bfs(0);
  delete M;
}

Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long x = long.Parse(Console.ReadLine());
            long result = 0;
            long yokin = 100;
            while (true)
            {
                if (x <= yokin)
                {
                    break;
                }
                yokin += yokin / 100;

                result++;
            }
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27500
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {
    // static final long MOD = 1000000007;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N;
        String S;
        int a = 0;
        int max = 0;
        N = scanner.nextInt();
        S = scanner.next();
        for (int i = 0; i < N; i++) {
            if(S.charAt(i) == 'I'){
                a++;
            }else{
                a--;
            }

            max = Math.max(a, max);

        }

        System.out.println(max);


    }





}




Measured memory_bytes: 9680
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int x, t;
	t = 0;
	scanf("%d", &x);
	for (int i = 0; i < x; i++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		t+=r-l+1;
	}
	printf("%d", t);
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    ll n, k;
    cin>>n>>k;
    vl x(n);
    forr(i, n)
    {
        cin>>x[i];
    }
    ll ans=INT_MAX;
    for(ll i=0; i<=n-k; i++)
    {
        ll min1=x[i];
        ll max1=x[i+k-1];
        if(min1<0&&max1>0)
        {
            ll temp1=abs(min1);
            temp1+=(max1-min1);
            ll temp2=abs(max1)+abs(max1-min1);
            temp1=min(temp1, temp2);
            ans=min(ans, temp1);
        }
        else
        {
            ll temp=max(abs(min1), abs(max1));
            ans=min(ans, temp);
        }
    }
    cout<<ans;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int a, b;
    string s;
    cin >> a >> b >> s;

    if ( s[a] != '-' ) {
        cout << "No\n";
        return 0;
    }

    fo(i, a + b + 1) {
        if ( i == a ) continue;
        if ( s[i] < '0' or s[i] > '9' ) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c int
		x       int
	)
	count := 0
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; a >= b; i++ {
		b *= 2
		count++
	}
	for i := 0; b >= c; i++ {
		c *= 2
		count++
	}
	if count <= x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1768
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n,k = invr()
    print(n - sorted(inlt() + [k]).index(k))
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 86640
N=int(input())
A=list(map(int,input().split()))
A=sorted(A,reverse=True)
if(A[-1]==0):
    print(0)
else:
    ans=1
    flag=0
    for i in range(N):
        ans=ans*A[i]
        if(ans>10**18):
            flag=1
            break
    if(flag==0):
        print(ans)
    else:
        print(-1)

Measured memory_bytes: 21788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,t,s;
    cin >> n >> t >> s;
    vi a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    //0~s, s~t で DP する
    vector<vi> dp1(n+1,vi(s+1)),dp2(n+1,vi(t-s+1));
    rep(i,n)rep(j,s+1){
        dp1[i+1][j] = max(dp1[i+1][j],dp1[i][j]);
        if(j+b[i] <= s)dp1[i+1][j+b[i]] = max(dp1[i+1][j+b[i]], dp1[i][j] + a[i]);
    }
    rep(i,n)rep(j,t-s+1){
        dp2[i+1][j] = max(dp2[i+1][j],dp2[i][j]);
        if(j+b[n-1-i] <= t-s)dp2[i+1][j+b[n-1-i]] = max(dp2[i+1][j+b[n-1-i]], dp2[i][j] + a[n-1-i]);
    }
    vector<vi> ma(2,vi(n+1));
    rep(i,n+1){
        rep(j,s+1)ma[0][i] = max(ma[0][i], dp1[i][j]);
        rep(j,t-s+1)ma[1][i] = max(ma[1][i], dp2[i][j]);
    }
    int ans = 0;
    rep(i,n+1){
        ans = max(ans, ma[0][i] + ma[1][n-i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 73708
n=int(input())
w=[str(input())]
ans="Yes"
for i in range(n-1):
    x=str(input())
    if x in w:
        ans="No"
        break
    w.append(x)
    y=w[i]
    if x[0]!=y[-1]:
        ans="No"
        break
print(ans)

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

int main(int argc, char const *argv[]) {
  string s,t; cin>>s>>t;
  vector<char> svec = *new vector<char>();
  vector<char> tvec = *new vector<char>();
  for(char c: s) svec.push_back(c);
  for(char c: t) tvec.push_back(c);

  sort(svec.begin(), svec.end());
  sort(tvec.begin(), tvec.end(), greater<char>());
  cout<< (svec < tvec ? "Yes" : "No") <<"\n";
  return 0;
}

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

int main() {
  int n, k;
  int scoreR, scoreS, scoreP; 
  string s;
  int score;
  
  cin >> n >> k;
  cin >> scoreR >> scoreS >> scoreP;
  cin >> s;
  
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'x') {
      continue;
    }
    if (i + k < s.size()) {
      if (s.at(i) == s.at(i + k)) {
        s.at(i + k) = 'x';
      }
    }
  }
  score = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'r') {
      score += scoreP;
    }
    if (s.at(i) == 's') {
      score += scoreR;
    }
    if (s.at(i) == 'p') {
      score += scoreS;
    }
  }
  //cout << s << endl;
  cout << score << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> a(100001);
vector<int> dp(100001,-1);
int topDown(int n,int i){
    if(dp[i]!=-1)
        return dp[i];
    if(i==n-1)
        return 0;

    int one = 1e18;
    int two = 1e18;

    if(i<n-1)
        one = abs(a[i]-a[i+1]) + topDown(n,i+1);
    if(i<n-2)
        two = abs(a[i]-a[i+2]) + topDown(n,i+2);

    return dp[i]=min(one,two);
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<topDown(n,0)<<'\n';
    



    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct UnionFind {
	vector<int>par;
	UnionFind(int n) :par(n) {
		for (int i = 0; i < n; i++)par[i] = i;
	}
	int root(int x) {
		return par[x] == x ? x : par[x] = root(par[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void merge(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
};

int main() {
	int n; cin >> n;
	vector<long long>x(n), y(n);
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i];
	using P = pair<int, int>;
	using edge = pair<long long, P>;
	vector<edge>edges;

	vector<int>ids(n);
	for (int i = 0; i < n; i++)ids[i] = i;
	sort(ids.begin(), ids.end(), [&](int i, int j) {return x[i] < x[j]; });
	for (int i = 0; i < n - 1; i++) {
		int u = ids[i], v = ids[i + 1];
		edges.push_back(edge(x[v] - x[u], P(u, v)));
	}
	sort(ids.begin(), ids.end(), [&](int i, int j) {return y[i] < y[j]; });
	for (int i = 0; i < n - 1; i++) {
		int u = ids[i], v = ids[i + 1];
		edges.push_back(edge(y[v] - y[u], P(u, v)));
	}
	sort(edges.begin(), edges.end());
	UnionFind uf(n);
	long long ans = 0;
	for (auto e : edges) {
		int u = e.second.first, v = e.second.second;
		long long cost = e.first;
		if (uf.same(u, v))continue;
		uf.merge(u, v);
		ans += cost;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8432
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int l[]=new int[n];
    for(int i=0;i<n;i++){
      l[i]=sc.nextInt();
    }
    sc.close();
    
    Arrays.sort(l);
    int sum=0;
    for(int i=0;i<k;i++){
      sum+=l[n-1-i];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 23124
n,q=map(int,input().split())
s=input()
cnt=[0]*n
for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    cnt[i]=cnt[i-1]+1
  else:
    cnt[i]=cnt[i-1]
for _ in range(q):
  l,r=map(int,input().split())
  print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 6188
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}


int main(void){
	int n,L;cin>>n>>L;
	if(0<L){cout<<n*(L+L+(n-1))/2-L<<endl;}
	else if(L+n-1<0){cout<<n*(L+L+(n-1))/2-L-n+1<<endl;}
	else{cout<<n*(L+L+(n-1))/2<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    int n;
    while(cin>>n,n){
        string e,f;
        //nを8進数に変換
        for(int i=0;;i++){
            e+=(n%8)+'0';
            n/=8;
            if(n==0)break;
        }
        //reverse
        for(int i=0;i<e.size();i++){
            f+=e[e.size()-i-1];
        }
        //'4'以上で++,さらにその状態で'6'以上なら++
        for(int i=0;i<f.size();i++){
            if(f[i]>='4')f[i]++;
            if(f[i]>='6')f[i]++;
        }
        cout<<f<<endl;
    }
    return 0;
}

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

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

    int n;
    n = s.length() - 1;

    if(s[n] == 's') {
        rep(i,n+1){
            cout << s[i];
        }
        cout << "es" << endl;
    }else{
        cout << s;
        cout << 's' << endl;
    }
}


Measured memory_bytes: 3628
def main():
    import bisect
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    for a in range(n):
        for b in range(a+1, n):
            c = bisect.bisect_left(inlis, inlis[a] + inlis[b])
            ans += c - b - 1
    print(ans)     



if __name__ == "__main__":
    main()


Measured memory_bytes: 74396