akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<long long int, long long int> P;

int main(void) {
	long long int n, k;
	long long int count = 0;
	long long int mini = 9e18;
	long long int result;

	cin >> n >> k;
	vector<long long int>x(n ), y(n), xx(n), yy(n);

	FOR(i, 0, n-1) {
		cin >> x[i] >> y[i];
		xx[i] = x[i];
		yy[i] = y[i];
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());


	mini = (x[n-1] - x[0])*(y[n-1] - y[0]);

	FOR(i, 0, n-1) {
		FOR(t, i+1, n-1) {
			FOR(p, 0, n-1) {
				FOR(q, p + 1, n-1) {
					count = 0;
					FOR(r, 0, n-1) {
						if (x[i] <= xx[r] && xx[r] <= x[t] && y[p] <= yy[r] && yy[r] <= y[q]) {
							count++;
						}
					}
					if (count >= k) {
						result = (x[t] - x[i])*(y[q] - y[p]);
						if (result < mini) {
							mini = result;
						}
					}
				}
			}
		}
	}
	cout << mini << endl;
	return 0;
}

Measured memory_bytes: 256
n = input()

ls = []
cnt = 0
for i in range(len(n)):
  if n[i] == 'A' or n[i] == 'G' or n[i] == 'C' or n[i] == 'T':
    cnt += 1
    ls.append(cnt)
  else:
    cnt = 0
    ls.append(cnt)
    
print(max(ls))

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


int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++) {
        if (s[i] == ',')
            cout << " ";
        else
            cout << s[i];
    }

    return 0;
}


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

 
public class Main{
	int N;
	int[] A;
	public void solve(){
		N = nextInt();
		A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = nextInt() - 1;
		}
		int ans = 0;
		for(int i = 0; i < N; i++){
			if(A[i] > i && A[A[i]] == i){
				ans++;
			}
		}
		out.println(ans);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
const int INF = 1e15;

struct Edge {
  int to, cost;
  Edge(int to, int cost): to(to), cost(cost) {}
};

int N, M;
vector<vector<Edge> > G;
vector<int> add[2];
bool zero = false;

void dfs(int v, int s, bool f) {
  if ( add[f][v] != INF ) {
    if ( add[f][v] != s ) zero = true;
    return;
  }
  add[f][v] = s;
  for ( Edge &e: G[v] ) {
    dfs(e.to, e.cost-s, !f);
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  G.resize(N);
  add[0].resize(N, INF);
  add[1].resize(N, INF);
  REP(i, M) {
    int u, v, s;
    cin >> u >> v >> s;
    u--; v--;
    G[u].push_back(Edge(v, s));
    G[v].push_back(Edge(u, s));
  }

  dfs(0, 0, 0);

  if ( zero ) {
    cout << 0 << endl;
    return 0;
  }
  /* REP(i, N) {
    cout << add[0][i] << " " << add[1][i] << endl;
  } */
  int ma = INF;
  int mi = 0;
  set<int> all;
  REP(i, N) {
    if ( add[0][i] != INF && add[1][i] != INF ) {
      if ( add[0][i] == add[1][i] ) {
        cout << 0 << endl;
        return 0;
      }
      if ( (add[1][i]-add[0][i])/2 <= 0 ) {
        cout << 0 << endl;
        return 0;
      }
      all.insert((add[1][i]-add[0][i])/2);
    }
    if ( add[0][i] != INF ) mi = max(mi, -add[0][i]);
    if ( add[1][i] != INF ) ma = min(ma, add[1][i]);
  }
  if ( add[1][0] != INF ) {
    if ( add[1][0] > 0 ) {
      int t = add[1][0]/2;
      if ( mi < t && t < ma ) cout << 1 << endl;
      else cout << 0 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  if ( all.size() == 1 ) {
    cout << 1 << endl;
  }
  else if ( all.size() > 1 ) {
    cout << 0 << endl;
  }
  else cout << max(0LL, ma-mi-1) << endl;

  return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

	char buf[201];
	fgets(buf,201,stdin);
	for(int i=0;buf[i]!='\0';i++){
		if(buf[i] >= 97 && buf[i] <=122){
			buf[i] -= 32;
		}
	}

	printf("%s",buf);
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (d[i] > d[i - 1]) {
			ans++;
		}
	}
	cout << ans << '\n';
	
	return 0;
}


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

#define MIN(a,b) ((a)<(b)?(a):(b))

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int *cnt=(int *)calloc(m,sizeof(int));
  int *x=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++){
    scanf("%d",x+i);
    cnt[x[i]%m]++;
  }
  qsort(x,n,sizeof(int),cmp);
  int ans=cnt[0]/2;
  cnt[0]%=2;
  for(i=1;i<m-i;i++){
    int v=MIN(cnt[i],cnt[m-i]);
    ans+=v;
    cnt[i]-=v;
    cnt[m-i]-=v;
  }
  if(i==m-i){
    ans+=cnt[i]/2;
    cnt[i]%=2;
  }
  i=0;
  while(i+1<n){
    if(x[i]==x[i+1] && cnt[x[i]%m]>=2){
      ans++;
      cnt[x[i]%m]-=2;
      i+=2;
    } else {
      i++;
    }
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1404
#include <iostream>
using namespace std;
int main(void){
    int n, ans = 0;
    string s;
    cin >> s;
    n = s.length();
    for(int i=0;i<n;i++){
        if(s[i] == 'g'){
            if(i%2==1)ans++;
        }else{
            if(i%2==0)ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  
  if(A >= 13){
    cout << B;
  } 
  if(6 <= A && A <= 12){
    cout << B/2;
  }
  if(A <= 5){
    cout << 0;
  }
}
    

Measured memory_bytes: 256
def inversion(A,N,K,M):
    B = [0 for _ in range(N)]
    C = [0 for _ in range(N)]
    #B[i]:i<j且つA[i]>A[j]を満たすjの個数
    #C[i]:A[i]<A[j]を満たすjの個数
    for i in range(N):
        for j in range(i+1,N):
            if A[i] > A[j]:
                B[i] += 1

    for i in range(N):
        for j in range(N):
            if A[i] > A[j]:
                C[i] += 1

    output = sum(B) * K
    output += sum(C) * K * (K-1) //2
    output %= M

    return output

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    M = 10**9+7

    print(inversion(A,N,K,M))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
N = int(input())
a = [int(input()) for _ in range(N)]
memo = set()
memo.add(0)
count = 1
i = a[0] - 1

while True:
  if i == 1:
    break
  i = a[i] - 1
  count += 1
  if i in memo:
    count = -1
    break
  else:
    memo.add(i)
print(count)

Measured memory_bytes: 15908
n=int(input())
a=[0]*n
x=[0]*n
y=[0]*n
for i in range(n):
  a[i]=int(input())
  x[i]=[0]*a[i]
  y[i]=[0]*a[i]
  for j in range(a[i]):
    x[i][j],y[i][j]=map(int,input().split())
#print(a)
#print(x)
#print(y)

pattern=[]
ans=0
for i in range(2**n):
  tmp=[0]*(n)
  for j in range(n):
    if i>>j & 1:
      tmp[j]=1
  pattern.append(tmp)
  #print(pattern[i])
  count=0
  flag=-1
  for j in range(n):
    if (pattern[i][j]==1):
      if (flag==-1):
        flag=0
      for k in range(a[j]):
          if (y[j][k]!=pattern[i][x[j][k]-1]):
            flag=1
            #print("x[j][k]",x[j][k],"y[j][k]",y[j][k])
      #print("for end")
  if (flag==0):
    count=sum(pattern[i])
    #print(j,flag)
  ans=max(ans,count)
  
print(ans)

Measured memory_bytes: 52188
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0;
  cin >>a>>b;
  a--,b--;
  cout <<a*b<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    int a[5];
    rep(i,5) cin >> a[i];
    int k;
    cin >> k;
    int max=a[0], min=a[0];
    rep(i,4) {
        max = MAX(max,a[i+1]);
        min = MIN(min,a[i+1]);
    }
    if(max-min>k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N,M,X=map(int,input().split())

listC=[]
listall=[]

for i in range(N):
    listC.append(list(map(int,input().split())))

for i in range(2**N):
    total=np.zeros(M+1)
    for j in range(N):
        
        if ((i >> j) & 1):
            total=total+np.array(listC[j])
            #print(total)
    listall.append(list(total))
            


#print(listall)
ans=[]
for i in range(len(listall)):
    flag=True
    for j in range(M):
        if listall[i][j+1] < X:
            #print(j,listall[i][j+1])
            flag=False
        if j==(M-1) and flag==True:
            ans.append(listall[i][0])

if len(ans)>0:
    print(int(min(ans)))
else:
    print("-1")

Measured memory_bytes: 29088
def aaa(n):
    n = [x for x in n]
    for i in range(len(n)-1,-1,-1):
        if n[i] == '3':
            n[i] = '5'
            for j in range(i+1,len(n)):
                n[j] = '3'
            return ''.join(n)
        elif n[i] == '5':
            n[i] = '7'
            for j in range(i+1,len(n)):
                n[j] = '3'
            return ''.join(n)
        else:
            pass
    n = '3'*(len(n)+1)
    return n
n = int(input())
check = '357'
ans = 0
if int(check) <= n:
    ans += 1
while True:
    if int(check) > n:
        break
    check = aaa(check)
    acheck = [0,0,0]
    for i in check:
        if i == '3':
            acheck[0] = 1
        if i == '5':
            acheck[1] = 1
        if i == '7':
            acheck[2] = 1
    if acheck[0] == 1 and acheck[1] == 1 and acheck[2] == 1 and int(check) <= n:
        ans += 1
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

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

func main() {
	s := readString()
	fmt.Println(strings.LastIndex(s, "Z") - strings.Index(s, "A") + 1)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

vector<vector<ll>> node;
deque<ll> ls;
vector<bool> flag;

void dfs(ll n){
    if(!flag[n]) return;
    
    flag[n] = false;
    for (auto e : node[n]) dfs(e);
    ls.push_front(n);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;

    node.resize(N);
    flag.resize(N, true);

    rep(i,M){
        ll x, y;
        cin >> x >> y;
        --x, --y;
        node[x].pb(y);
    }

    rep(i, N) dfs(i);

    vector<ll> dp(N);

    ll ans = 0;
    for (auto l : ls){
        for(auto n : node[l]){
            dp[n] = max(dp[n], dp[l] + 1);
            ans = max(ans, dp[n]);
        }
    }

    print(ans);

    return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

 
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin>>p[i];
  int cnt=0;
  for(int i=1;i<n-1;i++){
    if(p[i]!=max(p[i],max(p[i-1],p[i+1])) && p[i]!=min(p[i],min(p[i-1],p[i+1])))cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1000000007;
vector<int> g[100005];
int dist1[100005],dist2[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=0;i<n;i++)
		dist1[i]=INF,dist2[i]=INF;
	queue<int> q;
	q.push(0);
	dist1[0]=0;
	while(!q.empty())
	{
		int f=q.front();
		q.pop();
		for(int i=0;i<g[f].size();i++)
		{
			int s=g[f][i];
			if(dist1[s]==INF)
			{
				dist1[s]=dist1[f]+1;
				q.push(s);
			}
		}
	}
	q.push(n-1);
	dist2[n-1]=0;
	while(!q.empty())
	{
		int f=q.front();
		q.pop();
		for(int i=0;i<g[f].size();i++)
		{
			int s=g[f][i];
			if(dist2[s]==INF)
			{
				dist2[s]=dist2[f]+1;
				q.push(s);
			}
		}
	}
	int s1=0,s2=0;
	for(int i=0;i<n;i++)
		if(dist1[i]<=dist2[i])
			s1++;
		else
			s2++;
	if(s1>s2)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
	return 0;
}

Measured memory_bytes: 6656
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.container;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(long[] a) {
    a.sort();

    auto ps = new DList!long;
    auto ns = new DList!long;
    int psize = 0;
    int nsize = 0;
    foreach (x; a) {
        if (x >= 0) {
            ps.insertBack(x);
            psize++;
        }
        else {
            ns.insertBack(x);
            nsize++;
        }
    }

    if (ps.empty) {
        ps.insertBack(ns.back);
        ns.removeBack();
        psize++;
        nsize--;
    }
    else if (ns.empty) {
        ns.insertBack(ps.front);
        ps.removeFront();
        psize--;
        nsize++;
    }

    long[][] steps;
    while (psize > 1 || nsize > 1) {
        if (psize > nsize) {
            long x = ns.back; ns.removeBack();
            long y = ps.back; ps.removeBack();
            ns.insertBack(x - y);
            psize--;
            steps ~= [x, y];
        }
        else {
            long x = ps.back; ps.removeBack();
            long y = ns.back; ns.removeBack();
            ps.insertBack(x - y);
            nsize--;
            steps ~= [x, y];
        }
    }

    long x = ps.back;
    long y = ns.back;
    steps ~= [x, y];
    long ans = x - y;
    writeln(ans);
    foreach (s; steps) {
        writeln(s[0], " ", s[1]);
    }
}

void main() {
    readint;
    auto a = reads!long;
    calc(a);
}


Measured memory_bytes: 17948
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    string s;
    cin>>a;
    cin>>s;
    if(a<3200)
    {
        cout<<"red"<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <assert.h>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define RFOR(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 20+5;
int ans,num[MAXN];
int N,len;

void dfs(int step){
	if(step == len+1){
		int t = 0;
		bool a=0,b=0,c=0;
		FOR(i,1,len){
			if(num[i] == 3) a = 1;
			if(num[i] == 5) b = 1;
			if(num[i] == 7) c = 1;
		}
		if(!a || !b || !c) return;
		FOR(i,1,len) t = (t<<1) + (t<<3) + num[i];
		//DEBUG(t);
		if(t <= N) ans++;
		return;
	}
	if(step > 1){
		int t = 0;
		bool a=0,b=0,c=0;
		FOR(i,1,step-1){
			if(num[i] == 3) a = 1;
			if(num[i] == 5) b = 1;
			if(num[i] == 7) c = 1;
		}
		//DEBUG(a);DEBUG(b);DEBUG(c);
		if(a && b && c){
			FOR(i,1,step-1) t = (t<<1) + (t<<3) + num[i];
			//DEBUG(t);
			if(t <= N) ans++;
		}
	}
	num[step] = 7;
	dfs(step+1);
	num[step] = 5;
	dfs(step+1);
	num[step] = 3;
	dfs(step+1);
}

int main(){
	scanf("%d",&N);
	int t = N;
	while(t){
		len++;
		t /= 10;
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,k,n,i;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);
  n = 0;
  for ( i = a; i <= b ; i++) {
    if (i % k == 0) {
      n = 1;
      break;
    }
  }
  if (n == 0) {
    puts("NG\n" );
  }
  else {
    puts("OK\n");
  }
  return 0;
}


Measured memory_bytes: 1644
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m==-1 && f==-1 && r==-1){
                break;
            }
            if(m==-1 || f==-1){
                System.out.println("F");
            }else if(m+f>=80){
                System.out.println("A");
            }else if(m+f>=65 && m+f<80){
                System.out.println("B");
            }else if(m+f>=50 && m+f<65){
                System.out.println("C");
            }else if(m+f>=30 && m+f<50){
                if(r>=50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else{
                System.out.println("F");
            }
        }    
    sc.close();
    }
}


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

const char nl = '\n';

int counter = 0;

void solve()
{
    int n; cin >> n;
    map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    while (n--) {
        string s; cin >> s;
        ++m[s];
    }
    cout << "AC x " << m["AC"] << nl;
    cout << "WA x " << m["WA"] << nl;
    cout << "TLE x " << m["TLE"] << nl;
    cout << "RE x " << m["RE"] << nl;
}

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

Measured memory_bytes: 3668
def gcd(x , y):
    if x < y:
        x , y = y , x
    if y == 0:
        return x
    r = x % y
    return gcd(y , r)

N = int(input())
L = list(map(int,input().split()))
ans = L[0]
for i in range(len(L)):
    ans = gcd( ans ,L[i] )
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    // input
    ll A, B, K;
    cin >> A >> B >> K;
    
    // calculation
    ll mn = min(A, B), n = 0;
    for (ll i = mn; i >= 1; --i) {
        if (A%i == 0 && B%i == 0) ++n;
        if (n == K) {
            cout << i << "\n";
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int flag1,flag2,i,n,x,y,min;
    char a,b;
    flag1 = 1;
    flag2 = 0;
    i = 0;
    cin >> n;
    int num[100],num_bable[100],num_selection[100];
    char ch[100],ch_bable[100],ch_selection[100];
    for(int j = 0; j < n; j++){
        cin >> ch[j] >> num[j];
        ch_bable[j] = ch[j];
        ch_selection[j] = ch[j];
        num_bable[j] = num[j];
        num_selection[j] = num[j];
    }
    while (flag1){
        flag1 = 0;
        for(int j = n-1; j >= i + 1; j--){
            if(num_bable[j] < num_bable[j-1]){
                x = num_bable[j];
                y = num_bable[j-1];
                a = ch_bable[j];
                b = ch_bable[j-1];
                num_bable[j-1] = x;
                num_bable[j] = y;
                ch_bable[j-1] = a;
                ch_bable[j] = b;
                flag1 = 1;
                
            }
        }
        i ++;
    }
    for(int i = 0; i < n; i++){
        if(i != 0) cout << " ";
        cout << ch_bable[i] << num_bable[i];
    }
    cout << endl;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = 0; k < n; k++){
                for(int l = k+1; l < n; l++){
                    if(num_bable[i] == num_bable[j] && num_bable[i] == num[l] && num_bable[j] == num[k] && ch_bable[i] == ch[l] && ch_bable[j] == ch[k]){
                        flag2 = 1;
                    }
                }
            }
        }
    }
    if(flag2) cout << "Not stable" << endl;
    else cout << "Stable" << endl;
    
    min = 0;
    flag2 = 0;
    for(int i = 0; i < n; i++){
        min = i;
        for(int j = i + 1; j < n; j ++){
            if(num_selection[min] > num_selection[j]) min = j;
            
        }
        x = num_selection[min];
        y = num_selection[i];
        a = ch_selection[min];
        b = ch_selection[i];
        num_selection[min] = y;
        num_selection[i] = x;
        ch_selection[min] = b;
        ch_selection[i] = a;
    }
    for(int i = 0; i < n; i++){
        if(i != 0) cout << " ";
        cout << ch_selection[i] << num_selection[i];
    }
    cout << endl;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = 0; k < n; k++){
                for(int l = k+1; l < n; l++){
                    if(num_bable[i] == num_selection[j] && num_selection[i] == num[l] && num_selection[j] == num[k] && ch_selection[i] == ch[l] && ch_selection[j] == ch[k]){
                        flag2 = 1;
                    }
                }
            }
        }
    }
    if(flag2) cout << "Not stable" << endl;
    else cout << "Stable" << endl;
    
    return 0;
}


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

using namespace std;

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

    //最大公約数
    long long x,y,gcd=1;
    x = c;
    y = d;
    long long sw;
    if(y<x){
        sw = x;
        x = y;
        y = sw;
    }


    vector<long long> gc(1000,1);

    //xの約数
    int count=0;
    for(long long i=1;i*i<x;i++){
        if(x%i==0){
            count++;
            gc.at(count*2) = i;
            gc.at(count*2+1) = x/i;
        }
    }
    sort(gc.begin(),gc.end(),greater<long long>());

    for(long long i=0;i<gc.size();i++){
        if(y%gc.at(i)==0){
            gcd = gc.at(i);
            break;
        }
    }

    long long v = (c*d)/gcd;

    //個数判定
    long long da,db;
    da = (a-1) - ((a-1)/c + (a-1)/d - (a-1)/v); //aの個数
    db = b - (b/c + b/d - b/v); //bの個数
    long long ans;
    ans = db -da;
    cout<<ans<<endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A;
    int o[100010];
    int tmp;
    for (int i = 1; i <= N; i++)
    {
        cin >> tmp;
        o[tmp] = i;
    }

    for (int i = 1; i <= N; i++)
    {
        cout << o[i];
        if (i != N)
        {
            cout << ' ';
        }else
        {
            cout << endl;
        }

    }
    
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a, b, k;
    cin >> a >> b >> k;
    if(a <= k){
        k -= a;
        a = 0;
    }
    else{
        a -= k;
        k = 0;
    }
    if(b <= k){
        b = 0; 
    }
    else{
        b -= k;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
XY = []
YX = []
for i in range(N):
    x, y = map(int, input().split())
    XY.append([x, y, i])
    YX.append([y, x, i])
XY.sort()
YX.sort()

x_order = {}
for xo, p in enumerate(XY):
    x, y, i = p
    x_order[i] = xo

cums = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N):
    y, x, pi = YX[i]
    xo = x_order[pi]
    for j in range(N + 1):
        cums[i + 1][j] = cums[i][j] + (1 if j > xo else 0)

ans = float('inf')

for i in range(N-1):
    for j in range(i+1, N):
        for k in range(N-1):
            for l in range(k+1, N):
                if cums[l+1][j+1] - cums[l+1][i] - cums[k][j+1] + cums[k][i] >= K:
                        ans = min(ans, (XY[j][0]-XY[i][0]) * (YX[l][0]-YX[k][0]))

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <fstream>
#include<vector>

using namespace std;







int main()
{

	string str;

	cin >> str;


	int n;
	int minsa = 999999;
	for (int i = 0; i < str.size()-2; i++) {
		n = 0;
		n += (str[i] - '0') * 100;
		n += (str[i + 1] - '0') * 10;
		n += str[i + 2] - '0';

		if (abs(n - 753) < minsa) {
			minsa = abs(n - 753);
		}
	}

	cout << minsa << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}


int N,K;
int table[2005][2005];

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> K;
  const int L = 2*K;
  rep(i,N){
    int x,y;cin >> x >> y;
    char c; cin >> c;
    x%=L;
    y%=L;
    int black = 1;
    if(c=='W')black^=1;
    if(x>=K)black^=1;
    if(y>=K)black^=1;
    x%=K;
    y%=K;
    if(black){
      ++table[0][0];
      --table[0][y+1];
      --table[x+1][0];
      table[x+1][y+1]+=2;
    }else{
      ++table[0][y+1];
      ++table[x+1][0];
      table[x+1][y+1]-=2;
    }
  }
  rep(x,K)repp(y,1,K)table[x][y] += table[x][y-1];
  rep(y,K)repp(x,1,K)table[x][y] += table[x-1][y];
  int ans = 0;
  rep(x,K)rep(y,K){
    int t = N-table[x][y] > table[x][y] ? N-table[x][y]:table[x][y];
    ans = t > ans ? t : ans;
    //ans= max(ans,max(table[x][y],N-table[x][y]));
  }
  cout << ans << endl;
  return 0;
}



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

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, p: "List[int]"):
    counter = 0
    for i in range(N):
        if (i+1) != p[i]:
            counter += 1
    if counter == 2 or counter == 0:
        print('YES')
    else:
        print('NO')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n=int(input())
s=[]
count=n
if n==0:
    s.append(0)
while n!=0:
    if n%2==1:
        s.insert(0,1)
        n=(1-n)//2
    else:
        s.insert(0,0)
        n=-n//2
ans=map(str,s)
print(''.join(ans))

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

int main() {
  
  for (int i = 1; i < 10001; i++) {
    
    int x; cin >> x;
    
    if (x == 0) break;
    
    cout << "Case " << i << ": " << x << endl;
    
  }
  
}


Measured memory_bytes: 3008
#include<stdio.h>
#include<math.h>
long double triangle(long double d1[],long double d2[], long double d3[]){
	long double h1,h2,h3,s,S;
	h1=(long double)sqrt((double)((d3[1]-d2[1])*(d3[1]-d2[1])+(d3[0]-d2[0])*(d3[0]-d2[0])));
	h2=(long double)sqrt((double)((d3[1]-d1[1])*(d3[1]-d1[1])+(d3[0]-d1[0])*(d3[0]-d1[0])));
	h3=(long double)sqrt((double)((d1[1]-d2[1])*(d1[1]-d2[1])+(d1[0]-d2[0])*(d1[0]-d2[0])));
	s=(h1+h2+h3)/2.0;
	S=(long double)sqrt((double)(s*(s-h1)*(s-h2)*(s-h3)));
	return S;
}
int main(){
	long double a[5],b[5],c[5],d[4];
	for(;scanf("%llf,%llf,%llf,%llf,%llf,%llf,%llf,%llf",&a[0],&a[1],&b[0],&b[1],&c[0],&c[1],&d[0],&d[1])!=EOF;){
		if((triangle(a,b,d)+triangle(b,c,d))==(triangle(a,b,c)+triangle(a,c,d)))printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
   
      int N = sc.nextInt();
      Integer[] a = new Integer[N];

      for (int i = 0;i<N;i++){
        a[i] = sc.nextInt(); 
      }
      
      Arrays.sort(a,Collections.reverseOrder());
      
      int Alice=0;
      int Bob = 0;
      for (int i = 0;i<N;i++){
        if(i%2 == 0){
          Alice += a[i];  
        } else{
          Bob += a[i];  
        } 
      }
      System.out.println(Alice - Bob);
	}
}

Measured memory_bytes: 21844
program kadai
implicit none
    integer(8)  ::  a,b
    integer(8)  ::  max
    integer(8)  ::  p
    integer(8)  ::  i
    real(8)  ::sq_re
    integer(8)  ::  sq_in

    read(*,*) a,b
    max=gcd(a,b)

    sq_re=sqrt(real(max,8))
    sq_in=sq_re*1

    p=0
    do i=1,sq_in
        if (mod(max,i)==0) then
            p=p+1

            if (i>1) then
                do while(mod(max,i)==0)
                    max=max/i
                end do
            end if
        end if
    end do

    if(max/=1) then
        p=p+1
    end if

    write(*,*) p


stop
contains

function gcd(a,b) result(ret)
    implicit none
    integer(8),intent(in)  ::  a,b
    integer(8)  ::  l,m,n
    integer(8)  ::  ret
    m=a
    n=b
    do
        l=mod(m,n)
        if (l==0) then
            exit
        end if
        m=n
        n=l
    end do
    ret=n
    return
end function gcd

end program kadai

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


double getArea( double ang ) {
    double rad = ang / 180.0 * M_PI;
    return sin( rad );
}

double calc( VI v ) {
    double res = 0.0;
    int n = v.size();
    double rr = 360.0;
    for ( int i = 0; i < n; ++ i ) {
        res += getArea( v[i] );
        rr -= v[i];
    }
    res += getArea( rr );
    return res;
}

int solve( double s1, double s2 ) {
    if ( fabs( s1 - s2 ) < 1e-9 ) return 0;
    return s1 < s2 ? 2 : 1;
}

int main() {
    int m;
    while ( cin >> m && m ) {
        VI v1(m-1);
        for ( int i = 0; i < m-1; ++ i ) {
            cin >> v1[i];
        }
        int n;
        cin >> n;
        VI v2(n-1);
        for ( int i = 0; i < n-1; ++ i ) {
            cin >> v2[i];
        }
        double s1 = calc( v1 );
        double s2 = calc( v2 );
        cout << solve( s1, s2 ) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  ll n; cin >> n;
  ll sub = 1;
  rep(i, n) {
    ll a; cin >> a;
    if (a % 2 == 0) sub *= 2;
  }
  outl(ll(pow(3, n)) - sub);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

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

	int R, C, M;
	cin >> R >> C >> M;
	map<int, vector<int>> rows;
	map<int, set<int>> cols;
	set<pair<int, int>> colcnts;
	for (int i = 0; i < M; ++i) {
		int r, c;
		cin >> r >> c;
		--r;--c;
		rows[r].push_back(c);
		cols[c].insert(r);
	}
	for (auto& kv : cols) {
		colcnts.emplace(kv.second.size(), kv.first);
	}
	// cout << "ee" << endl;
	int ans = 0;
	for (auto& kv : rows) {
		int r = kv.first;
		for (int c : kv.second) {
			colcnts.erase(make_pair(cols[c].size(), c));
			colcnts.insert(make_pair(cols[c].size()-1, c));
		}
		// for (auto p : colcnts) {
		// 	cout << p.first << " " << p.second << endl;
		// }
		// cout << "ddd " << endl;
		ans = max(ans, (int)kv.second.size() + colcnts.rbegin()->first);
		for (int c : kv.second) {
			colcnts.erase(make_pair(cols[c].size()-1, c));
			colcnts.insert(make_pair(cols[c].size(), c));
		}
	}
	cout << ans << endl;
}

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

const ll MOD = 1000000007, INF = 10000000000000ll;

int main()
{
	ll N;
	cin >> N;
	vector<pair<ll, ll>> rang(N, pair<ll, ll>(1, INF));
	rang[0].second = rang[N + 1].second = 0;
	vector<ll> T(N + 2), A(N + 2);
	for (int i = 1; i <= N; i++) {
		cin >> T[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (int i = 1; i <= N; i++) {
		if (T[i - 1] < T[i]) {
			rang[i - 1].first = rang[i - 1].second = T[i];
		}
		else {
			rang[i - 1].second = T[i];
		}
	}
	for (int i = 1; i <= N; i++) {
		if (A[i + 1] < A[i]) {
			rang[i - 1].first = max(rang[i - 1].first, A[i]);
			rang[i - 1].second = min(rang[i - 1].second, A[i]);
		}
		else {
			rang[i - 1].second = min(rang[i - 1].second, A[i]);
		}
	}
	ll res = 1;
	for (int i = 0; i < N;i++) {
		if (rang[i].first <= rang[i].second) {
			res = (res * (rang[i].second - rang[i].first + 1)) % MOD;
		}
		else {
			res = 0;
			break;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3328
# デバッグ用
GBN_DEBUG = False
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
a, b, c = map(int, input().split())
#W = [input() for _ in range(N)]
#A = list(map(int, input().split()))

#GBN_DEBUG = True

if (a + b == c) or (b + c == a) or (c + a == b):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
n=int(input())
alist = list(map(int, input().split()))

alist=sorted(alist)
ng=len(alist)
if alist[0]>=0:
    print(sum(alist))
else:
    now=0
    switch=0
    while now<ng and switch==0:
        if alist[now]<0:
            now+=1
        else:
            switch=1
    if now%2==1:
        hidari=now-1
        wa=0
        for al in alist:
            wa+=abs(al)
        if ng==hidari+1:
            wa-=abs(alist[hidari]*2)
        else:
            wa-=min(abs(alist[hidari]), abs(alist[hidari+1]))*2
        print(wa)
    else:
        hidari=now
        wa=0
        for al in alist:
            wa+=abs(al)
        print(wa)

Measured memory_bytes: 64752
def test():
    n = int(input())
    t = list(map(int,input().split()))
    m = int(input())
    a = [];
    for i in range(m):
        p,x = map(int,input().split())
        s = t[p-1]
        t[p-1] = x
        a.append(sum(t))
        t[p-1] = s
    for i in range(len(a)):
        print(a[i])


if __name__ == "__main__":
    test()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  int r;
  cin >> r;
  cout << 2*r*M_PI << endl;
return 0;
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define forj(j,n) for(int j=n; j>=0; j--)
#define forx(x,v) for(auto &x:v)
#define sz(v) (int)(v).size()
#define rz(n) resize(n)
#define vec(x) vector < x >
using int64 = long long;
using vi = vector < int >;
using vi64 = vector < int64 >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
//const string yo = "Yes\n", no = "No\n";


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code

	string s, t;
	cin >> s >> t;
	int m = sz(t);
	int n = sz(s);
	int mx = m;
	for0(i, n - m + 1) {
		int tp = 0;
		for0(j, m) {
			if (t[j] != s[i + j]) tp++;
		}
		mx = min(mx, tp);
	}
	cout << mx;





	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
char s[4];
int LiangJiaJun(){
    scanf("%s",s+1);
    int A=0;
    for(int i=1;i<=3;i++)if(s[i]=='1')++A;
    printf("%d\n",A);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

alps = 'abcdefghijklmnopqrstuvwxyz'
ans = 0
for i in range(1,n):
    s1 = s[:i]
    s2 = s[i:]
    cnt = 0
    for alp in alps:
        if alp in s1 and alp in s2:
            cnt += 1
    ans = max(ans,cnt)

print(ans)

Measured memory_bytes: 64928
// 2019/11/20 Tazoe

#include <iostream>
#include <string>
using namespace std;

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

	string S;
	cin >> S;

	// ビットDP
	int DP[1001][1<<3];
	for(int j=0; j<(1<<3); j++){
		DP[0][j] = 0;
	}
	DP[0][1<<0] = 1;		// 0日目をJ君のみとする

	for(int i=1; i<=N; i++){
		for(int j=0; j<(1<<3); j++){
			DP[i][j] = 0;

			for(int k=0; k<(1<<3); k++){
				if((j&k)!=0){
					DP[i][j] += DP[i-1][k];
				}
			}

			DP[i][j] %= 10007;
		}

		int m;		// マスク
		if(S[i-1]=='J'){
			m = 1<<0;
		}
		else if(S[i-1]=='O'){
			m = 1<<1;
		}
		else if(S[i-1]=='I'){
			m = 1<<2;
		}

		for(int j=0; j<(1<<3); j++){
			if((j&m)==0){
				DP[i][j] = 0;
			}
		}
	}

	int sum = 0;

	for(int j=0; j<(1<<3); j++){
		sum += DP[N][j];
	}

	cout << sum%10007 << endl;

	return 0;
}



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

long long N;

long long calc(int N) {
    int res = 0;
    while (N > 0) {
        res += N % 10;
        N /= 10;
    }
    return res;
}

int main() {
    while (cin >> N) {
        long long res = 1LL<<60;
        for (long long i = 1; i < N; ++i) {
            long long j = N - i;
            long long tmp = calc(i) + calc(j);
            res = min(res, tmp);
        }
        cout << res << endl;
    }
}


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

int main(){

	int n,m,l;
	cin >> n >> m >> l;
	long long A[n][m];
	long long B[m][l];
	long long C[n][l];

	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			C[i][j]=0LL;
		}
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> A[i][j];
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<l; j++){
			cin >> B[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			for(int k=0; k<m; k++){
				C[i][j] += (A[i][k]*B[k][j]);			}
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<l; j++){
			cout << C[i][j] << ((j<l-1)? " ":"");
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

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

using namespace std;

int d[4] = {1,-1,4,-4};

int main()
{
	queue<string> que;
	map<string,int> ma;
	que.push("01234567");

	while(!que.empty())
	{
		string s = que.front();
		que.pop();

		int x = s.find("0");
		rep(i,4)
		{
			int b = x + d[i];
			if(0 <= b && b <= 7 && !(x == 3 && b == 4) && !(x == 4 && b == 3))
			{
				string next = s;
				char temp = next[x];
				next[x] = next[b];
				next[b] = temp;

				map<string,int>::iterator ite = ma.find(next);
				if(ite == ma.end())
				{
					que.push(next);
					ma[next] = ma[s] + 1;
				}
			}
		}
	}

	string s;
	while(cin >> s)
	{
		rep(i,7)
		{
			string temp;
			cin >> temp;
			s += temp;
		}

		cout << ma[s] << endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

const ll INF = LLONG_MAX;
class SegmentTree{
    int n;
    vector<ll> node;

public:
    SegmentTree(vector<ll> v){
        int size = v.size();
        n = 1;
        while(n < size) n *= 2;
        node.resize(2*n-1, INF);

        for(int i = 0; i < size; i++){
            node[n-1+i] = v[i];
        }
        for(int i = n-2; i >= 0; i--){
            node[i] = min(node[2*i+1], node[2*i+2]);
        }
    }

    int update(ll idx, ll val){
        idx += n-1;
        node[idx] = val;
        while(idx > 0){
            idx = (idx-1)/2;
            node[idx] = min(node[2*idx+1], node[2*idx+2]);
        }
    }

    //return min value within [a,b)
    //call get_min(a, b);
    ll get_min(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;

        if(b <= l || r <= a) return INF;

        if(a <= l && r <= b) return node[k];

        ll vl = get_min(a, b, 2*k+1, l, (l+r)/2);
        ll vr = get_min(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main(){
    ll N, x;
    cin >> N >> x;
    vector<ll> A(2*N);
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        A[N+i] = a;
    }

    SegmentTree seg(A);

    ll ans = LLONG_MAX;
    for(int s = 0; s < N; s++){
        ll tmp = x*s;
        for(int i = N; i < 2*N; i++) {
            ll c = seg.get_min(i-s, i+1);
            tmp += c;
        }
        chmin(ans, tmp);
    }

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


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

int main() {
ll a,b,k;
cin>>a>>b>>k;
if(a>=k)cout<<a-k<<" "<<b<<endl;
if(a<k&&k-a>=b)cout<<0<<" "<<0<<endl;
if(a<k&&k-a<b)cout<<0<<" "<<a+b-k<<endl;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        a: [usize; n],
    }

    let mut t = FenwickTree::from_vec(a);
    for _ in 0..q {
        input! {
            f: u8,
            l: usize,
            r: usize,
        };
        if f == 0 {
            t.add(l, r);
        } else {
            println!("{}", t.cum(l, r));
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};

impl<T: Copy + AddAssign + Integer> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn from_vec(v: Vec<T>) -> Self {
        let n = v.len();
        let mut t = Self::new(n);
        for i in 0..n {
            let v = t.v[i] + v[i];
            t.v[i] = v;
            let p = i + Self::lsb(i + 1);
            if p < n {
                t.v[p] += v;
            }
        }
        t
    }

    fn add(&mut self, mut i: usize, v: T) {
        while i < self.v.len() {
            self.v[i] += v;
            i += Self::lsb(i + 1);
        }
    }

    fn cum(&self, l: usize, r: usize) -> T {
        assert!(l <= r && r <= self.v.len());

        self.cum0(r) - self.cum0(l)
    }

    fn cum0(&self, mut r: usize) -> T {
        let mut v = zero();
        while r > 0 {
            v += self.v[r - 1];
            r -= Self::lsb(r);
        }
        v
    }

    fn lsb(i: usize) -> usize {
        i & i.wrapping_neg()
    }
}


Measured memory_bytes: 22984