akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main(){
  int a,b,c,d;
  double s,t,PI=acos(-1);
  //printf("%lf\n",PI);
  scanf("%d %d %d %d",&a,&b,&c,&d);
  s=(d/60.0)*2*PI;
  t=((c*60+d)/(12*60.0))*2*PI;
  //printf("%lf\n",s-t);
  printf("%.10lf\n",sqrt(a*a+b*b-2*a*b*cos(s-t)));
  return 0;
}
       


Measured memory_bytes: 2600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < num.length; i++) {
			num[i] = sc.nextInt();
		}
		int max = 0;
		for (int i = 0; i < num.length; i++) {
			max+=(num[i]-1);
		}
		System.out.println(max);

	}

}


Measured memory_bytes: 25264
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int b = 1;
    int count = 0;
    boolean sort = true;
    while(sort) {
      sort = false;
      for(int i = n - 1; i > b - 1; i--) {
        if(a[i] < a[i - 1]) {
          int v = a[i];
          a[i] = a[i - 1];
          a[i - 1] = v;
          sort = true;
          count++;
        }
      }
      b++;
    }
    for(int i = 0; i < n; i++) {
      if(i == n - 1) {
        System.out.println(a[i]);
      } else {
        System.out.print(a[i] + " ");
      }
    }
    System.out.println(count);
  }
}



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

int log10(int);
int main()
{
	int a,b;
	while(cin >> a >> b){
	cout << log10(a+b) << endl;
	}
	return 0;
}

int log10(int x)
{
	int i = 1;
	while(1){
		if(x/10 >= 1){
			i++;
			x = x / 10;
		}else{
			break;
		}
	}
	return i;
}

Measured memory_bytes: 1160
headData=[int(n) for n in input().split()]
cityNum=headData[0]
pos_x=int(headData[1])
cityList=[int(n) for n in input().split()]
allList=[]
allList.append(pos_x)
for n in cityList:
    allList.append(n)

allList=sorted(allList)

diffList=[]

for n in range(len(allList)-1):
    diffList.append(allList[n+1]-allList[n])

answer = min(diffList)

while True:
    isAnswer = True
    for n in diffList:
        if n % answer != 0:
            isAnswer = False
            break
    if isAnswer:
        print(answer)
        break
    else:
        answer = answer-1

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

int main(){
    int n;
    cin >> n;
    if(n %10 == 3 ){
        cout << "bon" << endl;
    }
    if(n %10 == 2 || n %10 == 4 || n %10 == 5 || n %10 == 7 || n %10 == 9){
        cout << "hon" << endl;
    }
    if(n %10 == 0 || n %10 == 1 || n %10 == 6 || n %10 == 8){
        cout << "pon" << endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;
template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); }

int solve(int n, const vector<int> & x, const vector<int> & y, const vector<int> & a) {
    constexpr int MAX_A = 0xf;
    assert (*max_element(ALL(a)) <= MAX_A);

    // make the adjacent list
    vector<vector<int> > g(n);
    REP (i, n - 1) {
        g[x[i]].push_back(y[i]);
        g[y[i]].push_back(x[i]);
    }

    // fix a root
    vector<int> parent(n, -1);
    constexpr int root = 0; {
        function<void (int)> go = [&](int i) {
            for (int j : g[i]) if (j != parent[i]) {
                parent[j] = i;
                go(j);
            }
        };
        go(root);
    }

    // move labels to nodes
    vector<int> b(n, -1);
    REP (i, n - 1) {
        if (parent[x[i]] == y[i]) {
            b[x[i]] = a[i];
        } else if (x[i] == parent[y[i]]) {
            b[y[i]] = a[i];
        } else {
            assert (false);
        }
    }

    // tree dp
    int removed = 0;
    function<int (int)> go = [&](int i) {
        int cnt1 = 0;
        for (int j : g[i]) if (j != parent[i]) {
            int cnt2 = go(j);
            REP (x, MAX_A + 1) if (cnt2 & (1 << x)) {
                removed += (bool)(cnt1 & (1 << x));
                cnt1 ^= 1 << x;
            }
        }
        int k = b[i];
        if (k != -1) {
            REP (x, MAX_A + 1) if (cnt1 & (1 << x)) {
                k ^= x;
            }
            if (k != 0) {
                removed += (bool)(cnt1 & (1 << k));
                cnt1 ^= 1 << k;
            }
        }
        return cnt1;
    };
    int cnt = go(root);

    // finialize
    constexpr int INF = 1e9 + 7;
    vector<int> dp(1 << (MAX_A + 1), INF);
    dp[0] = 0;
    REP (s, 1 << (MAX_A + 1)) if ((s | cnt) == cnt) {
        for (int t = 0; t != s; t = (t - s) & s) {  // t is a proper subset of s
            if (__builtin_popcount(s ^ t) == 1) {
                chmin(dp[s], dp[t] + 1);
            } else {
                int acc = 0;
                REP (x, MAX_A + 1) if ((s ^ t) & (1 << x)) {
                    acc ^= x;
                }
                if (acc == 0) {
                    chmin(dp[s], dp[t] + __builtin_popcount(s ^ t) - 1);
                }
            }
        }
    }
    return removed + dp[cnt];
}

int main() {
    // input
    int n; cin >> n;
    vector<int> x(n - 1), y(n - 1), a(n - 1);
    REP (i, n - 1) {
        cin >> x[i] >> y[i] >> a[i];
    }

    // solve
    int answer = solve(n, x, y, a);

    // output
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
  string s;
  cin >> s;
  int a = 0;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R')cout << 3 << endl;
    else if((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R'))cout << 2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R')cout << 1 << endl;
    else cout << 0;
  
  
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int sheep = sc.nextInt();
		int wolves = sc.nextInt();

		if(sheep > wolves){
			System.out.print("safe");
		}else{
			System.out.print("unsafe");
		}

	return;

	}
}


Measured memory_bytes: 27036
#include<stdio.h>
#include<math.h>
double x[100],y[100],d,t,u,a,b,s;
int n,i,j,k,m,c;
int main(void){
	for(;scanf("%d",&n),i=j=n;){
		m=1;
		for(;i--;scanf("%lf,%lf",x+i,y+i));
		for(i=n;--i;)
			for(j=i-1;j--;)
				if((d=hypot(x[j]-x[i],y[j]-y[i])/2)<=1)
					for(s=1,t=atan2(y[j]-y[i],x[j]-x[i]),u=acos(d);c=0,s+3;s-=2)
						for(a=x[i]+cos(t+s*u),b=y[i]+sin(t+s*u),k=n;k--;)
							hypot(a-x[k],b-y[k])<1+1e-7&&++c>m?m=c:0;
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

func nextLine() string {
    sc.Scan()
    return sc.Text()
}


func main(){
	S:=readLine()
	res:=0
	k:=0
	for i:=len(S)-1; i>=len(S)/2; i--{
		if S[i]!=S[k]{
			res++
		}
		k++
	}
	fmt.Println(res)
}


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

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

	if (x <= 3)
	{
		cout << 1 << endl;
		return 0;
	}

	int ans = 0;

	for (int b = 2; b * b <= x; b++)
	{
		for (int tmp = b * b; tmp <= x; tmp *= b)
		{
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main()
{
    int a,b,c,n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
    scanf("%d%d%d",&a,&b,&c);
    if((a+b>c)||(b+c>a)||(a+c>b))
    {
        if(((a*a)==(b*b)+(c*c)) || ((b*b)==(c*c)+(a*a)) || ((c*c)==(a*a)+(b*b)))
        printf("YES\n");
        else
        printf("NO\n");
    }
    else
    printf("NO\n");
}
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> Graph[N];
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        Graph[u].push_back(v);
    }
    int S, T;
    cin >> S >> T;
    S--;
    T--;
    vector<vector<int>> dis(N, vector<int>(3, INF));
    queue<pair<int, int>> que;
    que.push(make_pair(S, 0));
    dis[S][0] = 0;
    while(!que.empty()) {
        pair<int, int> p = que.front();
        que.pop();
        int now = p.first, mm = p.second;
        //cout << now << ':' << mm << endl;
        int d = dis[now][mm];
        int nextmm = (mm + 1) % 3;
        for(auto next : Graph[now]) {
            if(dis[next][nextmm] > d + 1) {
                dis[next][nextmm] = d + 1;
                que.push(make_pair(next, nextmm));
            }
        }
    }
    if(dis[T][0] == INF)
        cout << -1 << endl;
    else
        cout << dis[T][0] / 3 << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int gcd(int x, int y){
    if(y == 0) return x;
    else return gcd(y, x % y);
}

int main(){
    int t; cin>>t;
    while(t--){
        ll h, w; cin>>h>>w;
        ll GCD = gcd(h, w);
        h /= GCD;
        w /= GCD;

        if(h == 1 && w == 1){
            cout << 1 << " " << 0 << endl;
        }
        else if(h % 2 == 0 || w % 2 == 0){
            cout << 1 << " " << 1 << endl;
        }
        else{
            cout << w * h / 2 + 1 << " " << w * h / 2 << endl;
        }
    }
}


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

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

  if(n*a < b) cout << n*a << endl;
  else cout << b << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;

// 二分探索
int binarySearch(int key)
{
    int left = 0;
    int right = n;
    int mid;

    while (left < right)
    {
        mid = (left + right) / 2;
        if (A[mid] == key)
        {
            return 1;
        }
        else if (A[mid] > key)
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }
    return 0;
}

int main()
{
    int i, q, k, sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &A[i]);
    }

    // 受け取りつつ探索
    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &k);
        if (binarySearch(k))
        {
            sum++;
        }
    }
    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 2952
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
       
    
 	if(x>=30){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}


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

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

#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    ll sum = 0; 
    for (int i=1; i<=n; i++) {
       if (i%3==0 or i%5==0) continue;
       sum += i;
    }
    cout << sum << endl;

    return 0;
}




Measured memory_bytes: 3648
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

struct Edge
{
	int src, dst;
	int weight;
	Edge(int src, int dst, int weight) : src(src), dst(dst), weight(weight) {}

	bool operator< (const Edge& e)const
	{
		return weight != e.weight ? weight > e.weight :
			src != e.src ? src < e.src : dst < e.dst;
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void Dijkstra(const Graph& g, int s, vi& dist, vi& prev)
{
	int n = g.size();
	dist.assign(n, INT_MAX);
	dist[s] = 0;
	prev.assign(n, -1);
	
	priority_queue<Edge> Q;
	Q.push(Edge(-2, s, 0));

	while(!Q.empty()){
		Edge e = Q.top();
		Q.pop();
		if(prev[e.dst] != -1)
			continue;
		prev[e.dst] = e.src;

		rep(i, g[e.dst].size()){
			int pw = e.weight + g[e.dst][i].weight;
			if(dist[g[e.dst][i].dst] > pw){
				dist[g[e.dst][i].dst] = pw;
				Q.push(Edge(g[e.dst][i].src, g[e.dst][i].dst, pw));
			}
		}
	}
}


vi buildPath(const vi& prev, int t)
{
	vi path;
	for(int u = t; u >= 0; u = prev[u])
		path.push_back(u);
	reverse(path.begin(), path.end());
	return path;
}

int main()
{
	int c, n, m, s, d;
	while(scanf("%d%d%d%d%d", &c, &n, &m, &s, &d), c){
		--s; --d;
		Graph g(n*(c+1));
		rep(i, m){
			int a, b, f;
			scanf("%d%d%d", &a, &b, &f);
			--a; --b;

			rep(j, c+1){
				g[j*n+a].push_back(Edge(j*n+a, j*n+b, f));
				g[j*n+b].push_back(Edge(j*n+b, j*n+a, f));
				if(j){
					g[(j-1)*n+a].push_back(Edge((j-1)*n+a, j*n+b, f/2));
					g[(j-1)*n+b].push_back(Edge((j-1)*n+b, j*n+a, f/2));
				}
			}
		}

		vi dist, prev;
		Dijkstra(g, s, dist, prev);

		int ans = INT_MAX;
		rep(j, c+1){
			ans = min(ans, dist[j*n+d]);
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1012
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var (
		sdash string
		t     string
	)

	fmt.Scan(&sdash)
	fmt.Scan(&t)

	can := false

	var slice []string
	for i := 0; i <= len(sdash)-len(t); i++ {

		s := sdash[i:]
		// if len(s) < len(t) {
		// 	break
		// }

		// fmt.Println(s)

		for j := 0; j < len(t); j++ {
			if string(t[j]) == string(s[j]) || string(s[j]) == "?" {
				can = true
			} else {
				can = false
				break
			}
		}

		if can {

			slice = append(slice,
				strings.Replace(
					strings.Join([]string{
						string(sdash[:i]),
						string(t),
						string(sdash[i+len(t):]),
					}, ""), "?", "a", -1))
		}

	}

	if len(slice) != 0 {
		// fmt.Println(slice)
		sort.Strings(slice)
		fmt.Println(slice[0])
	} else {
		fmt.Println("UNRESTORABLE")
	}

}


Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????????????´¢
"""
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

inp = input().strip()
w = inp.translate(str.maketrans(upper,lower))
s = ""
while True:
    inp = input().strip()
    if inp == "END_OF_TEXT":
        break
    s = s + " " + inp.translate(str.maketrans(upper,lower))
arr = s.split()
print(arr.count(w))

Measured memory_bytes: 7416
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){
     
    vector<int> prime;
    vector<bool> check(10002);
     
    REP(i, 2, 10001){
        if(!check[i]) prime.push_back(i);
        for(int j  = 2; i * j < 10001; j++){
            check[i * j] = true;
        }
    }
 
    vector<ll> ans(10002, 0);
    ans[0] = 1;
 
    rep(i, prime.size()){
        int tmp = 0;
        for(int j = 0; i + j < prime.size(); j++){
            tmp += prime[i + j];
            if(tmp > 10001) break;
            ans[tmp]++;
        }
    }
     
 
    ll num;
    while(cin >> num, num){
        cout << ans[num] << endl;
    }
     
  
    return 0;
}

Measured memory_bytes: 3200
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=2e5+5;

class SegmentTree{
private:
	int sz;
	ll dat[maxn<<2],add[maxn<<2];
	inline void pushDown(int x){
		add[x<<1]+=add[x];
		add[x<<1|1]+=add[x];
		dat[x<<1]+=add[x];
		dat[x<<1|1]+=add[x];
		add[x]=0;
		return;
	}
public:
	SegmentTree(){}
	inline int size(){return sz;}
	inline void init(int n){
		for(sz=1;sz<n;sz<<=1);
		memset(dat,0,sizeof(dat));
		memset(add,0,sizeof(add));
		return;
	}
	inline void update(int x,int l,int r,int s,int t,ll k){
//		if(x==1) printf("update: %d %d %lld\n",s,t,k);
		if(l>t||r<s) return;
		if(l>=s&&r<=t){
//			printf("x=%d dat[x]=%lld k=%lld\n",x,dat[x],k);
			dat[x]+=k;
			add[x]+=k;
			return;
		}
		int md=(l+r)>>1;
		pushDown(x);
		update(x<<1,l,md,s,t,k);
		update(x<<1|1,md+1,r,s,t,k);
		dat[x]=max(dat[x<<1],dat[x<<1|1]);
		return;
	}
	inline ll query(int x,int l,int r,int s,int t){
		if(l>t||r<s) return 0;
		if(l>=s&&r<=t) return dat[x];
		int md=(l+r)>>1;
		pushDown(x);
		ll vl=query(x<<1,l,md,s,t);
		ll vr=query(x<<1|1,md+1,r,s,t);
		return max(vl,vr);
	}
	inline void print(int x,int l,int r){
//		printf("x=%d l=%d r=%d dat=%lld add=%lld\n",x,l,r,dat[x],add[x]);
		if(l==r) return;
		int md=(l+r)>>1;
		print(x<<1,l,md);
		print(x<<1|1,md+1,r);
		return;
	}
}seg;

int n,m;
ll dp[maxn],sum[maxn];
vector<pii> cov[maxn];

int main(){
	scanf("%d%d",&n,&m);
	seg.init(n+1);
	FOR(i,0,m){
		int l,r,w;
		scanf("%d%d%d",&l,&r,&w);
		cov[r].PB(MP(l,w));
		seg.update(1,0,seg.size()-1,l,r,-w);
		sum[l]+=w;sum[r+1]-=w;
	}
	REP(i,1,n+1) sum[i]+=sum[i-1];
	REP(i,1,n){
//		seg.print(1,0,seg.size()-1);
		dp[i]=seg.query(1,0,seg.size()-1,0,i-1)+sum[i];
		FOR(j,0,cov[i].size()){
			seg.update(1,0,seg.size()-1,cov[i][j].fst,i,cov[i][j].snd);
//			seg.print(1,0,seg.size()-1);
		}
		seg.update(1,0,seg.size()-1,i,i,dp[i]);
//		printf("sum[%d]=%lld dp[%d]=%lld\n",i,sum[i],i,dp[i]);
	}
	printf("%lld\n",seg.query(1,0,seg.size()-1,0,n));
	return 0;
}


Measured memory_bytes: 26752
let () =
    try
        while true do
            let a1, b1, c1, a2, b2, c2 = Scanf.scanf "%f %f %f %f %f %f\n" (fun a1 b1 c1 a2 b2 c2 -> a1, b1, c1, a2, b2, c2) in
            let a = (a1*.b2 -. a2*.b1) in
            let x = (c1*.b2 -. c2*.b1) /. a +. 0.0 in
            let y = (a1*.c2 -. a2*.c1) /. a +. 0.0 in
            Printf.printf "%.3f %.3f\n" x y
        done
    with
        End_of_file -> ()

Measured memory_bytes: 2248
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int w,n;
  cin>>w>>n;
  vector<int> row(w);
  rep(i,w)row[i]=i+1;
  rep(i,n){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(row[--a],row[--b]);
  }
  rep(i,w)
    cout<<row[i]<<endl;


}

Measured memory_bytes: 1240
#include <string>
#include <memory>
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#include <array>

using namespace std;

vector<vector<int>> graph;
vector<int> colors;
vector<bool> used;

bool Dfs(int v, int col, int* sz) {
  used[v] = true;
  colors[v] = col;
  (*sz)++;
  bool ans = false;
  for (const auto& to : graph[v]) {
    if (!used[to]) {
      if (Dfs(to, 1 - col, sz)) {
        ans = true;
      }
    } else {
      if (colors[to] == col) {
        ans = true;
      }
    }
  }
  return ans;
}

int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  cin >> n >> m;
  graph.resize(n);
  colors.resize(n);
  used.resize(n);

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  std::array<int64_t, 2> arr{};
  int64_t one = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      int sz = 0;
      if (Dfs(i, 0, &sz)) {
        arr[0]++;
      } else if (sz == 1) {
        one++;
      } else {
        arr[1]++;
      }
    }
  }
  int64_t ans = one * 1ll * n * 2 - one * one;
  cout << arr[0] * arr[0] + 2 * arr[0] * arr[1] + 2 * arr[1] * arr[1] + ans  << endl;
}

Measured memory_bytes: 14724
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = (1<<21);


int main(void){
  int n; cin >> n;
  int A[n];rep(i,n){cin >> A[i];}
  int L[n]; L[0] = A[0];
  int length = 1;

  rep(i,n){
    if(L[length -1] < A[i]){
      L[length] = A[i];
      length += 1;
    }else{
      *lower_bound(L, L + length, A[i]) = A[i];
    }

  //  cout << length << endl;
  }

  cout << length << endl;

  return 0;
}

Measured memory_bytes: 1940
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int N, M;
	struct edge { int from, to, cost; };
	vector<edge> es;
	vector<int> d;

	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		es.push_back(edge{ a - 1, b - 1, -c });
	}
	d.assign(N, INF_L);
	d[0] = 0;

	for (int v = 0; v < N - 1; ++v) {

		bool update = false;
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if (d[e.from] != INF_L && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}

		if (!update) break;
	}

	bool negative[1000];
	for (int i = 0; i < N; ++i) {
		negative[i] = false;
	}
	for (int loop = 0; loop < N; ++loop) {
		for (int i = 0; i < M; ++i) {
			edge e = es[i];
			if (d[e.from] != INF_L && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				negative[e.to] = true;
			}
			if (negative[e.from] == true) {
				negative[e.to] = true;
			}
		}
	}



	cout << (negative[N - 1] ? "inf" : to_string(-d[N - 1])) << endl;




	return 0;
}


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

int main(){
    int X;
    cin >> X;
    
    if (X > 10000) {
        cout << 1 << endl;
        return 0;
    }
    
    vector<bool> ans(10005, false);
    ans[0] = true;
    for (int i = 0; i <= 5; i++) {
        for (int j = 0; j <= 10004-100-i; j++) {
            if (ans[j]) ans[j+100+i] = true;
        }
    }
    
    if (ans[X]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = nk[0];
        int K = nk[1];

        var vList = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var vListRev = vList.Reverse().ToArray();


        //「左からA回, 右からB回, 取り出して、残りを突っ込む」をシミュレート
        int max = int.MinValue;

        for (int A = 0; A <= K; A++)
        {
            if (vList.Length < A) break;

            for (int B = 0; B <= K - A; B++)
            {
                if (vList.Length < (A + B)) break;

                int remain = K - A - B;

                var left = vList.Take(A);
                var right = vListRev.Take(B);

                var val = 0;

                int cnt = 0;

                foreach(var x in left.Concat(right).OrderBy(n => n))
                {
                    //都合の悪いのは回数分だけSumから除外可能
                    if (x < 0 && cnt < remain)
                    {
                        cnt++;
                        continue;
                    }
                    val += x;
                }


                max = Math.Max(val, max);
            }
        }

        Console.WriteLine(max);
    }


}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

vi32 cnt(100001);

void solve() {
  cnt[0] = 3;
  int n;
  cin >> n;
  mint ans = 1;
  rep(i, n) {
    int a;
    cin >> a;
    ans *= cnt[a];
    cnt[a]--;
    cnt[a + 1]++;
  }
  cout << ans << endl;
}


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

int main(){
    int n;
    cin>>n;
    ll a[n],b[n];
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll sum=0;
    rep(i,n){
        a[i]-=b[i];
        sum+=a[i];
    }
    if(sum<0){
        cout<<-1<<endl;
        return 0;
    }
    sort(a,a+n);
    ll mi=0;
    int cnt1=0;
    rep(i,n)if(a[i]<0){
        mi+=a[i];
        ++cnt1;
    }
    int cnt=0;
    while(mi<0){
        mi+=a[n-1-cnt];
        ++cnt;
    }
    cout<<cnt+cnt1<<endl;
    return 0;
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define mp make_pair

int main(){
ll n, sum = 0, ans = 0;
std::map<ll, ll> a;
a[0] = -1;
scanf("%lld", &n);
REP(i, n){
  ll tmp;
  scanf("%lld", &tmp);
  sum += tmp;
  auto it = a.find(sum);
  if(it == a.end()) a[sum] = i;
  else ans = max(ans, i - it->second);
}
printf("%lld\n", ans);
}


Measured memory_bytes: 15676
use std::io::stdin;

fn main() {
    let mut s1 = String::new();
    stdin().read_line(&mut s1).unwrap();

    let mut s2 = String::new();
    stdin().read_line(&mut s2).unwrap();
    let vec: Vec<i32> = s2
        .trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let k: i32 = s1.trim().parse().unwrap();
    let a = vec[0];
    let b = vec[1];

    let mut ret = "NG";
    for x in a..b + 1 {
        if x % k == 0 {
            ret = "OK";
            break;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    if(s.size() == 2)cout << s << endl;
    else cout << s[2] << s[1] << s[0] << endl;
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define w(t) int t;cin>>t;while(t--)
#define mod 1000000007



int main(){
	
		fast
		string s;
		cin>>s;
		if(s[s.size()-1]=='s')
			cout<<s<<"es";
		else
			cout<<s<<"s";


	return 0;
}





Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String N = sc.next();
            int sum = 0;
            for (int i = 0; i < N.length(); i++) {
                int n = N.charAt(i) - '0';
                sum += n;
            }
            System.out.println(sum % 9 == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 31464
from collections import deque
num=int(input())
A=deque()
for i in range(num):
    lst=list(map(int,input().split()))
    if lst[0]==0:
      if lst[1]==0:
        A.appendleft(lst[2])
      else :A.append(lst[2])
    elif lst[0]==1:
        print(A[lst[1]])
    elif lst[0]==2:
      if lst[1]==0:
         A.popleft()  
      else :A.pop()           


Measured memory_bytes: 21976
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
l = []
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            cnt += (k + 1) * k // 2 if j > i else k * (k - 1) // 2
print(cnt % 1000000007)

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 300010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

int h[MAX];
int dp[MAX];
int n,k;

int call(int pos) {
    if(pos>=n) return 0;
    if(dp[pos]!=-1) return dp[pos];

    int ret = INF;

    for(int i=1;i<=k and pos+i<=n;i++) {
        ret = min( ret , abs(h[pos]-h[pos+i]) + call(pos+i) );
    }
    return dp[pos] = ret;
}


int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    si(n);
  	k = 2;
    
    for(int i=1;i<=n;i++) si(h[i]);
    
    SET(dp);
    printf("%d\n",call(1));
    
    return 0;
}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int n,a[100005];
long long ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-1;i++)
	{
		ans+=a[i]>>1;
		a[i]%=2;
		int m=min(a[i],a[i+1]);
		ans+=m;
		a[i]-=m;
		a[i+1]-=m;
	}
	for(int i=0;i<n;i++)
		ans+=a[i]>>1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

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

void solve(long long N, long long M, std::string S, std::string T){
    ll L = lcm(N, M);
    ll a = L/N, b = L/M;
    ll c = gcd(M, N);
    ll n = N/c, m = M/c;
    for(ll p=0; p < c; p++){
        if(S[p*n]!= T[p*m]){
            cout << -1 << endl; 
            return;
        }
    }
    cout << L << endl;  
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, M, S, T);
    return 0;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int cnt = 0;
	int k = 1;
	for(int i = 0; i < n; i++) {
		if(arr[i] != k) {
			cnt++;
		}
		else {
			k++;
		}
	}
	if(cnt == n) {
		cout << -1;
	}
	else {
		cout << cnt;
	}
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 4380
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL f[10010];
struct node{int w,s,v;}a[1010];
int n,m;
bool cmp(node a,node b) {return a.s-b.w>b.s-a.w;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d %d %d",&a[i].w,&a[i].s,&a[i].v);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i].w;j<=10000;j++) f[min(j-a[i].w,a[i].s)]=max(f[min(j-a[i].w,a[i].s)],f[j]+a[i].v);
		f[a[i].s]=max(f[a[i].s],(LL)a[i].v);
	}
	LL ans=0;
	for(int i=0;i<=10000;i++) ans=max(ans,f[i]);
	printf("%lld",ans);
}

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcode abc 177

int inPlaceSame(string a, string b){
    int count =0;
    int al = a.length();

    for (int i = 0; i < al; ++i)
    {
        if(a[i]==b[i])
            count++;
    }
    return count;
}


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

    int result = 0;

    int sl = s.length();
    int tl = t.length();

    for (int i = 0; i <= sl-tl; ++i)
    {
        result = max(result, inPlaceSame(s.substr(i, tl), t));
    }

    cout<<tl-result<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>

int main(int argc, char* argv[])
{
  int p[2000], n, i;
  double ave, a;

  scanf("%d", &n);
  while(n != 0){
    ave = 0.0;
    for(i = 0; i < n; i++){
      scanf("%d", &p[i]);
      ave += p[i];
    }
    ave /= n;

    a = 0.0;
    for(i = 0; i < n; i++){
      a += (p[i]-ave)*(p[i]-ave);
    }
    a = sqrt(a/n);

    printf("%lf\n", a);
    scanf("%d", &n);
  }
  return(0);
}

Measured memory_bytes: 640
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

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

    int H, W;
    cin >> H >> W;
    vector<string> board(H);
    vector<vector<int>> dist(H, vector<int>(W, -1));

    rep(i, H) cin >> board[i];

    int cnt = 0;
    rep(i, H) rep(j, W) {
        if(board[i][j] == '#') cnt++;
    }

    queue<pair<int, int>> que;
    dist[0][0] = 0;
    que.push({0, 0});

    while(!que.empty()) {
        pair<int, int> next = que.front();
        que.pop();
        int y = next.first, x = next.second;
        if(y == H - 1 && x == W - 1) break;

        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if(ny < 0 || ny >= H || nx < 0 || nx >= W || dist[ny][nx] != -1)
                continue;
            if(board[ny][nx] == '#') continue;

            dist[ny][nx] = dist[y][x] + 1;
            que.push({ny, nx});
        }
    }

    int rel = dist[H - 1][W - 1];
    if(rel == -1)
        COUT(-1);
    else
        COUT(H * W - (rel + 1) - cnt);
}


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

string s;

bool check(){
	int a[100];
	for(int i=0;i<100;i++){
		a[i]=0;
	}
	for(int i=0;i<s.length();i++){
		a[s[i]-'a']+=1;
	}
	for(int i=0;i<100;i++){
		if(a[i]>1) return false;
	}
	return true;
}

int main(){
	cin >> s;
	cout << (check()?"yes":"no") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		if (a > b)
			System.out.println(a - 1);
		else
			System.out.println(a);

	}
}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }return 0;
}


Measured memory_bytes: 3116
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)

a = Array.new(n)

m.times do
  s, c = gets.chomp.split.map(&:to_i)

  if !a[s-1].nil? && a[s-1] != c
    puts -1
    exit
  end

  a[s-1] = c
end
start = 0
e = 9
if n == 2
  start = 10
  e = 99
elsif n == 3
  start = 100
  e = 999
end
start.upto(e) do |i|
  s = i.to_s.split(//).map(&:to_i)
  flg = true
  n.times do |j|
    next if a[j].nil?
    if a[j] != s[j]
      flg = false
      break
    end
  end
  if flg
    puts i
    exit
  end
end

puts -1


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

using namespace std;

int main() {
    /*int a,b,h,s;
    cin >> a >> b >> h;
    
    s=(a+b)*h/2;
    
    cout << s << endl;*/
    
    /*int N,A,B;
    cin >> N >> A;
    B=N*N-A;
    
    cout << B << endl;*/
    
    int A,B,C,D,s1,s2;
    cin >> A >> B >> C >> D;
    
    s1=A*B;
    s2=C*D;
    
    if(s1>s2){
        cout << s1 << endl;
    }
    else if(s1<s2){
        cout << s2 << endl;
    }
    else{
        cout << s1 << endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int N,A[100110],K;
int dp[100110];

int DP(int a){
	if(dp[a]!=-1)return dp[a];
	vector<int> v;
	if(a==N-1){
		return 0;
	}
	DEB(a)END
	for(int i=1;i<=K;i++){
		if(a<N-i){
			v.push_back(DP(a+i)+abs(A[a]-A[a+i]));
		}
	}
	return dp[a]=(*min_element(v.begin(),v.end()));
}

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,100010){
		dp[i]=-1;
	}
	cout<<DP(0)<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,VI(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

ll fac(ll n){  // 階乗
	ll sum = 1;
	for(ll i=1; i <= n; i++){ sum = sum * i % mod; }
	return sum;
}

int main() {
  ll n, m, k, x, y , z = 0, h, ans=0, w, sum = 0, Max = -1, Min = 1e9+1;
  string u= "";
  bool ok=true;
  cin >> n >> m;
  if(abs(n-m)>1)
    pri(0);
  else if(n==m)
    pri(2*fac(n)*fac(m)%mod);
  else
    pri(fac(n)*fac(m)%mod);
  return 0;
}


Measured memory_bytes: 256