akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
def main():
    readline=stdin.readline
    N,M=map(int,readline().split())
    A=[]
    for i in range(N):
        s=readline().strip()
        A.append(s)
    B=[]
    for i in range(M):
        s=readline().strip()
        B.append(s)
    
    for i in range(N-M+1):
        for j in range(N-M+1):  #左上
            flag=True

            for k in range(M):
                for l in range(M):
                    if B[k][l]!=A[k+i][l+j]:
                        flag=False
                        break
                if flag==False:
                    break
            if flag:
                break
        if flag:
            break
    if flag:
        print("Yes")
    else:
        print("No")
        
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
dp=[0]*110000

n=int(input())
h=list(map(int,input().split()))

dp[0]=0
for i in range(1,n):
  if i==1:
    dp[i]=dp[i-1]+abs(h[i]-h[i-1])
  else:
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),
              dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])

Measured memory_bytes: 14872
//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    lli mina=1e18;
    string s,t;
    cin>>s>>t;
    for(lli i=0;i<s.size()-t.size()+1;++i){
            //cout<<"i : "<<i<<endl;
            lli temp=0;
        for(lli j=0;j<t.size();++j){
            if(t[j]!=s[i+j]){
                temp++;
            }
        }
        mina=min(mina,temp);
    }
    cout<<mina<<endl;
return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct PY{
    int P;
    long long int Y;
    int A=1;
}py[100000];
bool comp(PY x,PY y){
    if(x.P==y.P){
        return x.Y<y.Y;
    }
    else{
        return x.P<y.P;
    }
}
int main(){
    string s[100001];
    int n,m,a=1;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>py[i].P>>py[i].Y;
        if(i>=1){
            py[i].A=py[i-1].A+1;
        }
    }
    sort(py,py+m,comp);
    for(int i=0;i<m;i++){
        if(i>=1&&py[i].P!=py[i-1].P){
            a=1;
        }
        int b=a;
        while(b>0){
            s[py[i].A]=char((b%10)+48)+s[py[i].A];
            b/=10;
        }
        b=6-s[py[i].A].length();
        for(int j=1;j<=b;j++){
            s[py[i].A]='0'+s[py[i].A];
        }
        b=py[i].P;
        while(b>0){
            s[py[i].A]=char((b%10)+48)+s[py[i].A];
            b/=10;
        }
        b=12-s[py[i].A].length();
        for(int j=1;j<=b;j++){
            s[py[i].A]='0'+s[py[i].A];
        }
        a++;
    }
    for(int i=1;i<=m;i++){
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 9344
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

double dp[3100][3100]={};
//dp[i][j]:=最初のi枚のコインを投げた時に、表がj枚になる確率


int main(){
int N;
cin>>N;
double p[N+1];
for(int i=1;i<=N;i++)cin>>p[i];
dp[0][0]=1;
//dp[1][1]=p[0];
//dp[1][0]=1-p[0];
rep(i,N+1){
    rep(j,i+1){
        dp[i+1][j+1]+=dp[i][j]*p[i+1];
        dp[i+1][j]+=dp[i][j]*(1-p[i+1]);
    }
}
double ans=0;

for(int i=(N+1)/2;i<=N;i++)ans+=dp[N][i];

printf("%.10f\n",ans);

 return 0;
}
/*
3
0.30 0.60 0.80

0.612

1
0.50

0.5

5
0.42 0.01 0.42 0.99 0.42

0.3821815872
*/

Measured memory_bytes: 72320
#include<bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  if (str=="q"||str=="w"||str=="e"||str=="r"||str=="t"||str=="y"||str=="u"||str=="i"||str=="o"||str=="p"||str=="a"||str=="s"||str=="d"||str=="f"||str=="g"||str=="h"||str=="j"||str=="k"||str=="l"||str=="z"||str=="x"||str=="c"||str=="v"||str=="b"||str=="n"||str=="m"){
    cout << "a" << endl;
  }
  else {
    cout << "A" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
vector<int> g[N];
int f[N],dp[N];
void dfs(int v,int p=-1){
	int c=0,w=0,k=0;
	for(int to:g[v])
		if(to^p){
			dfs(to,v);
			k=to;
			c++;
			if(f[to])dp[v]++,w=1;
			else dp[v]+=dp[to];
		}
	if(w)dp[v]--;
	f[v]=((c==1&&f[k])||c==0);
	dbg(v,f[v],dp[v]);
}	
int32_t main(){
	int n;
	cin>>n;
	forn(i,n-1){
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	if(n==2){
		cout<<"1\n";
		return 0;
	}
	int s=0;
	for(int i=0;i<n;++i)if(sz(g[i])>sz(g[s]))s=i;
	dfs(s);
	dbg(s);
	cout<<dp[s]<<'\n';

    return 0;
}


Measured memory_bytes: 18252
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		var a = Console.ReadLine().Split().Select(nyan => int.Parse(nyan)).ToArray();
		int k = a[0];
		int x = a[1];
		
		if(500*k >= x){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
		
		
	}
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	int M; cin >> M;
	vector<int> b(M);
	rep(j, M) cin >> b[j];
	map<int, int> mp;
	rep(i, N) mp[a[i]]++;
	rep(j, M) mp[b[j]]--;
	for (auto p: mp) if (p.second < 0) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
    int ninzu=0;
    while(cin >> ninzu,ninzu){
        int ans=0;
        int i=0;
        int temp=0;
        int a=0;
        
        vector <int>  s;
        
        
        for(i=0;i<ninzu;i++){
            cin >> a;
            if(temp < a){
                temp = a;
            }
            s.push_back(a);
        }
        
        sort( ALL(s) );
        
        for(i=0;i<s.size()-1;i++)
            ans+= s[i];
        
        ans = (ans- s[0]) / (i-1);
        
        cout << ans << endl;
        ans=0;
    }
    
    return 0;
}

Measured memory_bytes: 1220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
 
using static Input;
using static Util;
class Program
{
    static string S;
    static void INPUT()
    {
        S = NextString();
    }
    static void OUT()
    {
        var c = S.ToCharArray();
      	if(c[2] == c[3] && c[4] == c[5])
        	Console.WriteLine(string.Format("Yes"));
        else
			Console.WriteLine(string.Format("No"));
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();
 
#else
        INPUT();
#endif
        OUT();
    }
 
    static void TESTINPUT()
    {
    }
 
}
 
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}
 
class Util
{
}
 
 

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<vector>

int main() {
    int a, b; std::cin >> a >> b;

    int ans = 0;
    for(int i = a; i <= b; i++) {
        std::string num = std::to_string(i);

        bool f = true;
        for(int j = 0; j < num.size() / 2; j++) {
            if(num[j] != num[num.size() - 1 - j]) {
                f = false;
            }
        }

        if(f) {
            ans ++;
        }
    }

    std::cout << ans << "\n";
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep0c(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)
#define repc0(n, i) for (int i = (int)(n); i >= 0; i--)

using namespace std;
typedef long long ll;

typedef pair<int, int> BA;
int N;
vector<BA> bas;

void solve() {
  int t = 0;
  for(const BA& ba : bas) {
    t += ba.second;
    if(ba.first < t) {
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
  return;
}

int main() {
  scanf("%d", &N);
  rep(i, N) {
    int a, b;
    scanf("%d %d", &a, &b);
    bas.push_back(make_pair(b, a));
  }
  sort(bas.begin(), bas.end());
  solve();
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
/*深さ優先探索。pathの軌跡をvectorの形で表し、スタックに保存する。*/
int main(void){
    int N, M;
    cin >> N >> M;
    bool relation[N][N];
    int ans = 0;
    rep(i,N)rep(j,N)relation[i][j] = false;
    rep(i,M){
        int x,y;
        cin >> x >> y;
        relation[x-1][y-1] = true;
        relation[y-1][x-1] = true;
    }
    deque<vector<int>> will_search;
    vector<int> start = {0};
    will_search.emplace_back(start);
    while(!will_search.empty()){
        vector<int> locus = will_search.back();
        will_search.pop_back();
        int now_search = locus.back();
        rep(i,N){
            if(!relation[now_search][i] || count(locus.begin(),locus.end(),i) != 0)continue;
            locus.emplace_back(i);
            if((int)locus.size() == N)ans++;
            else will_search.emplace_back(locus);
            locus.pop_back();
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    bool not_p[1000001] = {0};
    vector<int> primes;
    for(int i=2;i<=1'000'000;++i){
        if(not_p[i]) continue;
        primes.push_back(i);
        for(int j=2;i*j<=1'000'000;++j) not_p[i*j] = true;
    }
    int64_t a, b;
    cin >> a >> b;
    vector<int64_t> common;
    common.push_back(1);
    for(int p : primes){
        if(a%p == 0 && b%p == 0) common.push_back(p);
        while(a%p == 0) a /= p;
        while(b%p == 0) b /= p;
    }
    if(a>1 && a==b) common.push_back(a);

    cout << common.size() << endl;

    return 0;
}

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=1e5+10;
int n;
char a[maxn];
int main()
{
    while(scanf("%s",a)!=EOF)
    {
        int ans=0;
        int len=strlen(a);
        for(int i=1; i<len-1; i++)
            if(a[i-1]!=a[i+1])ans++;
        if(ans==0)
        {
            printf("Second\n");
            continue;
        }
        if(a[0]!=a[len-1])printf("%s\n",len%2?"First":"Second");
        else printf("%s\n",len%2?"Second":"First");
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

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

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

uint64_t dec_dig(uint64_t num) {
  uint64_t res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

uint64_t gcd(uint64_t a, uint64_t b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

uint64_t lcm(uint64_t a, uint64_t b) { return a * b / gcd(a, b); }

int main() {
  uint64_t N, M;
  cin >> N >> M;

  if (N != M) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll uni[100005];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    int n,m,ans=0;
    cin>>n>>m;
    int a,b,c;
    multiset<pair<int,pair<int,int> > > ms;
    for(int i=0;i<m;i++){
    	cin>>a>>b>>c;
    	ms.insert(make_pair(c,make_pair(a,b)));
    }
    for(auto& i:ms){
    	if(root(i.second.first)!=root(i.second.second)){
    		connect(i.second.second,i.second.first);
    		ans+=i.first;
    	}
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 10252
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod ((ll)(1e9 + 7))
using namespace std;

int n;
string s;
map<string,int> m;

void solve()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}

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

const int maxn = 200000+16;

int n;
vector<int> g[maxn];
int d1[maxn], d2[maxn];

void dfs(int p, int last, int d, int wd[]) {
   wd[p] = d;
   for (int x : g[p]) {
      if (x != last) {
         dfs(x, p, d+1, wd);
      }
   }
}

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) {
      g[i].clear();
   }
   for (int i = 0; i < n-1; i++) {
      int x, y;
      cin >> x >> y;
      --x, --y;
      g[x].push_back(y);
      g[y].push_back(x);
   }
   dfs(0, -1, 0, d1);
   dfs(n-1, -1, 0, d2);

   int ret = 0;
   for (int i = 0; i < n; i++) {
      if (d1[i] <= d2[i]) {
         ++ret;
      } else {
         --ret;
      }
   }

   puts(ret>0?"Fennec":"Snuke");

   return 0;
}

Measured memory_bytes: 15104
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){

    string s; cin >> s;
    int k; cin >> k;
    set<string> aa;
    rep(i, s.length()){
        for(int j = 0; j < k; ++j){
            aa.insert(s.substr(i, j + 1));
        }
    }
    auto it = aa.begin();
    rep(i, k - 1) it++;
    cout << *it << endl;

  
}

Measured memory_bytes: 1664
#include <stdio.h>

#define N 100

int count = 0;

void bubbleSort(int *,int);
void swap(int *,int *);

int main(){
  int length,A[N],i;

  while(1){
    scanf("%d",&length);
    if(1 <= length && length <= 100) break;
  }

  for(i = 0;i < length;i++){
    scanf("%d",&A[i]);
    if(A[i] < 0 || 100 < A[i]) i = i - 1;
  }
  bubbleSort(A,length);

  for(i = 0;i < length - 1;i++) printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",count);
  return 0;
}

void bubbleSort(int *p,int l){
  int flag = 1;
  int i = 0,j;
  while(flag){
    flag = 0;
    for(j = l - 1;j >= 1;j--){
      if(p[j] < p[j-1]){
	swap(&p[j],&p[j-1]);
	flag = 1;
      }
      i++;
    }
  }
}

void swap(int *q,int *r){
  int tmp;
  tmp = *q;
  *q = *r;
  *r = tmp;
  count++;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

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


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int ans = 0;
        int ans_cnt = -1;
        for (int i = 1; i <= n; i++) {
            int tmp = i;
            int cnt = 0;
            while (true) {
                if (tmp % 2 == 0) {
                    cnt++;
                } else {
                    break;
                }
                tmp /= 2;
            }
            if (ans_cnt < cnt) {
                ans_cnt = cnt;
                ans = i;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<queue>
#define INF 100000000
using namespace std;
int main(){
  int n;cin>>n;
  int u,k,v,c;
  int mp[101][101],d[101];
  for(int i=0;i<=100;i++){
    d[i]=INF;
    for(int j=0;j<=100;j++)mp[i][j]=INF;
  }
    while(u!=n-1){
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v>>c;
      if(mp[u][v]>c)mp[u][v]=c;
    }
  }
    d[0]=0;
    queue<int>p;
    p.push(0);
    int mn,s,cnt=n,t[101]={};
    t[0]=1;
    while(!p.empty()){
      s=p.back();
      mn=INF;
      for(int i=0;i<n;i++){
	if(t[i]==0){
	if(d[i]>d[s]+mp[s][i])d[i]=d[s]+mp[s][i];
	  if(mn>d[i])mn=d[i],k=i;
	}
      }
      if(mn!=INF)t[k]=1,p.push(k);
      else p.pop();
    }
    for(int i=0;i<n;i++)cout<<i<<" "<<d[i]<<endl;
    
  return 0;
}

Measured memory_bytes: 1240
// OBツ嘉ッツ嘉債宿2011 Day3 H : Palindrome Generator

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cstring>

using namespace std;

class Node{
public:
	int diff, Lidx, Ridx, cost;
	Node(int diff, int Lidx, int Ridx, int cost) : diff(diff), Lidx(Lidx), Ridx(Ridx), cost(cost) {}
	bool operator < (const Node &nd) const { return cost < nd.cost; }
};

int main(){
	int N, M;
	int dp[21][100][100];
	string str[100];
	const int INF = 1000000007;
	while(cin >> N >> M){
		for(int i=0;i<N;i++) cin >> str[i];
		vector< vector<int> > f(N, vector<int>()), b(N, vector<int>());
		for(int i=0;i<M;i++){
			int x, y; cin >> x >> y;
			f[x-1].push_back(y-1);
			b[y-1].push_back(x-1);
		}
		priority_queue<Node> qu;
		memset(dp, 0, sizeof(dp));
		for(int i=0;i<N;i++){
			qu.push(Node(10+str[i].size(), i, i, str[i].size()));
			for(int j=0;j<str[i].size();j++){
				bool ok = true;
				for(int k=0;k<j-k;k++)
					if(str[i][k]!=str[i][j-k]) ok = false;
				if(ok) qu.push(Node(10+str[i].size()-(j+1), i, i, str[i].size()));
			}
			qu.push(Node(10-str[i].size(), i, i, str[i].size()));
			for(int j=str[i].size()-1;j>=0;j--){
				bool ok = true;
				for(int k=0;j+k<str[i].size()-k-1;k++)
					if(str[i][j+k]!=str[i][str[i].size()-k-1]) ok = false;
				if(ok) qu.push(Node(10-str[i].size()+(str[i].size()-j), i, i, str[i].size()));
			}
		}
		bool first = false;
		while(!qu.empty()){
			Node nd = qu.top(); qu.pop();
			int diff = nd.diff, Lidx = nd.Lidx, Ridx = nd.Ridx, c = nd.cost;
			if(dp[diff][Lidx][Ridx] >= c) continue;
			if(dp[diff][Lidx][Ridx] > 1000) c = INF;
			dp[diff][Lidx][Ridx] = c;
			if(diff <= 10){
				for(int i=0;i<f[Ridx].size();i++){
					string back = str[Lidx];
					string fwd  = str[f[Ridx][i]];
					bool ok = true;
					int len = 10-diff;
					for(int j=0;j<min(len, (int)fwd.size());j++)
						if(back[len-1-j]!=fwd[j]) ok = false;
					if(!ok) continue;
					int nc = min(INF, c+(int)fwd.size());
					if(dp[diff+fwd.size()][Lidx][f[Ridx][i]] < nc)
						qu.push(Node(diff+fwd.size(), Lidx, f[Ridx][i], nc));
				}
			}
			if(diff >= 10){
				for(int i=0;i<b[Lidx].size();i++){
					string fwd  = str[Ridx];
					string back = str[b[Lidx][i]];
					bool ok = true;
					int len = diff-10;
					for(int j=0;j<min(len, (int)back.size());j++)
						if(back[back.size()-1-j]!=fwd[fwd.size()-len+j]) ok = false;
					if(!ok) continue;
					int nc = min(INF, c+(int)back.size());
					if(dp[diff-back.size()][b[Lidx][i]][Ridx] < nc)
						qu.push(Node(diff-back.size(), b[Lidx][i], Ridx, nc));
				}
			}
		}
		int mx = 0;
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++)
				mx = max(mx, dp[10][i][j]);
		cout << (mx < INF ? mx : -1) << endl;
	}
}

Measured memory_bytes: 0
N = int(input())
T, A = list(map(int,input().split()))
lst1 = list(range(1,N+1))
lst2 = list(map(int,input().split()))
com_lst = dict(zip(lst1,lst2))
#print(com_lst)
Ans = com_lst[1]
for i in range(1,N+1):
	AveT = T - 0.006 * com_lst[i]
	AbsD = abs(A - AveT)
	#print(AveT,AbsD,Ans)
	if AbsD < Ans:
		Ans_1 = com_lst[i]
		Ans = AbsD
		#print(Ans_1)

#keys = [k for k, v in com_lst.items() if v == Ans_1]
#print(keys)

def inverse_lookup(d, x):
    for k,v in com_lst.items():
        if x == v:
            return k
print(inverse_lookup(com_lst, Ans_1))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,p,q,x,y,res;
int main(){
  cin>>x>>y>>n>>p>>q;
  while(--n){
    cin>>x>>y;
    x-=p; y-=q;
    if(x*y<0)res+=abs(x)+abs(y);
    else res+=max(abs(x),abs(y));
    p+=x; q+=y;
  }
  cout<<res<<endl;
}

Measured memory_bytes: 1160
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc169_c.cpp"

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

  ll a;
  cin >> a;
  string b;
  cin >> b;
  ll up = b[0] - '0';
  ll down = (b[2] - '0') * 10 + b[3] - '0';
  ll bb = up * 100 + down;

  cout << a * bb / 100 << endl;
}


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

void sort(int* n, int len){
	int tmp;
	for(int i=0; i<len; i++){
		for(int j=len-1; j>i; j--){
			if(n[j] > n[j-1]){
				tmp=n[j];
				n[j]=n[j-1];
				n[j-1]=tmp;
			}
		}
	}
}
int desc(const void *a, const void *b){
	return *(int *)b - *(int *)a;
}

int main(void){
	int x,y,a,b,c;
	scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
	int p[a];
	int q[b];
	int r[c];
	int ans[x+y+c];
	long long int d=0;
	for(int i=0; i<a; i++){
		scanf("%d",&p[i]);
	}
	for(int i=0; i<b; i++){
		scanf("%d",&q[i]);
	}
	for(int i=0; i<c; i++){
		scanf("%d",&r[i]);
	}
	qsort(p,sizeof(p)/sizeof(*p),sizeof(*p),desc);
	qsort(q,sizeof(q)/sizeof(*q),sizeof(*q),desc);
	for(int i=0; i<x; i++){
		ans[i]=p[i];
	}
	for(int i=0; i<y; i++){
		ans[i+x]=q[i];
	}
	for(int i=0; i<c; i++){
		ans[i+x+y]=r[i];
	}
	qsort(ans,sizeof(ans)/sizeof(*ans),sizeof(*ans),desc);
	for(int i=0; i<x+y; i++){
		d+=ans[i];
	}
	printf("%lld\n",d);

	return 0;

}



Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<30)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(){
	while(1){
	int y,m,d;
	string g;
	cin>>g;
	if(g=="#")break;
	cin>>y>>m>>d;
	if(y>31){
		y-=30;
		g="?";
	}
	else if(y==31&&m>4){
		y-=30;
		g="?";
	}
	cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

map<int,vector<int>> edges;
bool done[100001];
int ans[100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m,a,b;
    cin>>n>>m;
    for (int i=0;i<m;++i)
    {
        cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    done[1]=1;
    while (!q.empty())
    {
        a=q.front();
        q.pop();
        for (auto v : edges[a])
            if (!done[v])
            {
                q.push(v);
                done[v]=1;
                ans[v]=a;
            }
    }
    for (int i=2;i<=n;++i)
        if (!done[i])
        {
            cout<<"No\n";
            return 0;
        }
    cout<<"Yes\n";
    for (int i=2;i<=n;++i)
        cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 16164
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int MAX_N = 1e5 + 5;
int longest_path[MAX_N];
vector <int> graph[MAX_N];

int dfs(int v)
{
    if(longest_path[v] != -1)
    {
        return longest_path[v] ;
    }

    int longest_child_path = 0;

    for(int i = 0; i < graph[v].size(); i++)
    {
        int child = graph[v][i];

        longest_child_path = max(longest_child_path, dfs(child));
    }

    longest_path[v] = 1 + longest_child_path;

    return longest_path[v] ;
}

int main()
{
    int no_of_vertices, no_of_edges;
    cin >> no_of_vertices >> no_of_edges;

    for(int i = 1; i <= no_of_edges; i++)
    {
        int x, y;
        cin >> x >> y;

        graph[x].push_back(y);
    }

    memset(longest_path, -1, sizeof(longest_path));

    int vertices_on_longest_path = 0;

    for(int i = 1; i <= no_of_vertices; i++)
        vertices_on_longest_path = max(vertices_on_longest_path, dfs(i));

    int edges_on_longest_path = vertices_on_longest_path - 1;

    cout << edges_on_longest_path;

    return 0;
}

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

using namespace std;
int main ()
{   
    string S,T;
    cin >> S >> T; 
    map<char,int> sm,tm;
    int cnt=0;
    vector<int> sv,tv;
    for(int i=0;i<S.size();i++){
        if(sm[S[i]]==0){
            cnt++;
            sv.push_back(cnt);
            sm[S[i]]=cnt;
        }else sv.push_back(sm[S[i]]);
    }
    cnt=0;
    for(int i=0;i<T.size();i++){
        if(tm[T[i]]==0){
            cnt++;
            tv.push_back(cnt);
            tm[T[i]]=cnt;
        }else tv.push_back(tm[T[i]]);
    }
   
    
    if(tv==sv) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}












Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  int n; cin >> n;
  map<string,int> m;
  int maxnum = 0;
  FOR(i,0,n-1){
    string s; cin >> s;
    ++m[s];
    chmax(maxnum,m[s]);
  }

  for(auto x: m){
    if(x.second==maxnum) cout << x.first << endl;
  }

  
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

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

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b) ; }
template<typename T> T power(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}

void read(vt<int> &a) {
    rep(i,0,a.size()) 
        cin >> a[i] ; 
}
void read(vt<ld> &a) {
    rep(i,0,a.size()) 
    cin >> a[i] ; 
}

bool prime(ll t) {
    for(ll i  =2 ; i*i <= t ; ++i) {
        if(t%i==0) 
            return 0 ; 
    }
    return 1 ; 
}
bool cmp(pii &a , pii &b) {
    if(a.ss == b.ss) 
        return a.ff > b.ff ; 
    return a.ss < b.ss ; 
}

// ==========Start Here==============



int main() 
{ 
    int d, t , s ; 
    cin >> d >> t >> s ; 
    cout << ((s*t >= d ) ? "Yes" : "No" ); 
    return 0; 
} 

Measured memory_bytes: 3608
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

vll dp(101, vl(100001));

int main(){
    int N, W; cin >> N >> W;
    int WE[101];
    int V[101];
    rep(i, 0, N){
        int w, v;
        cin >> w >> v;
        WE[i] = w;
        V[i] = v;
    }
    rep(w, 0, W+1) dp[0][w] = 0;
    rep(i, 1, N+1){
        rep(w, 0, W+1){
            if(w - WE[i-1] >= 0){
                dp[i][w] = max(dp[i-1][w], dp[i-1][w-WE[i-1]] + V[i-1]);
            } else {
                dp[i][w] = dp[i-1][w];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<string.h>

#define Mtw 1046527
#define NIL (-1)
#define Ltw 14

char Htw[Mtw][Ltw];


int getChar(char ch){
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}


long long getKey(char str[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++){
        sum += p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key % Mtw; }
int h2(int key){return 1+(key%(Mtw-1));}

int find(char str[]){
    long long key, i, h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%Mtw;
        if(strcmp(Htw[h],str)==0)return 1;
        else if(strlen(Htw[h])==0)return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key,i,h;
    key=getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%Mtw;
        if(strcmp(Htw[h],str)==0)return 1;
        else if(strlen(Htw[h])==0){
            strcpy(Htw[h],str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i,n,h;
    char strtw[Ltw],comtw[9];
    for(i=0;i<Mtw;i++)Htw[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",comtw,strtw);

        if(comtw[0]=='i'){
            insert(strtw);
        }else{
            if(find(strtw)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16056
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 998244353;

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> used(n);
	queue<int> q;
	q.push(0);
	vector<int> ans(n, -1);
	used[0] = 1;
	while (!q.empty()) {
		int c = q.front();
		q.pop();
		for (auto u : g[c]) {
			if (!used[u]) {
				used[u] = 1;
				q.push(u);
				ans[u] = c + 1;
			}
		}
	}
	ans[0] = 0;
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (ans[i] == -1)ok = false;
	}
	if (ok) {
		cout << "Yes\n";
		for (int i = 1; i < n; i++) {
			cout << ans[i] << "\n";
		}
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 10688
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	public static void main(String[] args) {
		while (true) {
			int M = sc.nextInt();
			if (M == 0) break;
			int N = sc.nextInt();
			int[] B = new int[M];
			for (int i = 0; i < M; ++i) {
				B[i] = sc.nextInt();
			}
			int[] R = new int[N];
			for (int i = 0; i < N; ++i) {
				R[i] = sc.nextInt();
			}
			BiMatching bm = new BiMatching(M, N);
			for (int i = 0; i < M; ++i) {
				for (int j = 0; j < N; ++j) {
					if (gcd(B[i], R[j]) != 1) bm.addEdge(i, j);
				}
			}
			System.out.println(bm.matching());
		}
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	static class BiMatching {
		ArrayList<ArrayList<Integer>> left = new ArrayList<ArrayList<Integer>>();
		ArrayList<ArrayList<Integer>> right = new ArrayList<ArrayList<Integer>>();
		int[] l2r, r2l;

		BiMatching(int n, int m) {
			l2r = new int[n];
			r2l = new int[m];
			Arrays.fill(l2r, -1);
			Arrays.fill(r2l, -1);
			for (int i = 0; i < n; ++i) {
				left.add(new ArrayList<Integer>());
			}
			for (int i = 0; i < m; ++i) {
				right.add(new ArrayList<Integer>());
			}
		}

		void addEdge(int ln, int rn) {
			left.get(ln).add(rn);
			right.get(rn).add(ln);
		}

		int matching() {
			int res = 0;
			for (int i = 0; i < left.size(); ++i) {
				if (l2r[i] != -1) continue;
				boolean[] visited = new boolean[right.size()];
				for (int j = 0; j < left.get(i).size(); ++j) {
					if (dfs(left.get(i).get(j), visited)) {
						l2r[i] = left.get(i).get(j);
						r2l[left.get(i).get(j)] = i;
						++res;
						break;
					}
				}
			}
			return res;
		}

		boolean dfs(int rn, boolean[] visited) {
			int l = r2l[rn];
			if (l == -1) {
				return true;
			}
			visited[rn] = true;
			for (int i = 0; i < left.get(l).size(); ++i) {
				int r = left.get(l).get(i);
				if (visited[r]) continue;
				if (dfs(r, visited)) {
					r2l[r] = l;
					l2r[l] = r;
					return true;
				}
			}
			return false;
		}
	}

}

Measured memory_bytes: 67424
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#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 pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
void solve(){
     cout<<fixed<<setprecision(10);
     double x;
     cin>>x;
     x=2*(3.14000)*x;
     cout<<x;
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


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

int main(){
    // 1. 入力情報取得.
    int N, K;
    scanf("%d %d", &N, &K);
    
    // 2. ボールの個数の差としてあり得る最大値.
    // K = 1 の 場合, 最大: N,         最小: N
    // K > 1 の 場合, 最大: N + 1 - K, 最小: 1
    int maxB = 0, minB = 0;
    if(K == 1) maxB = minB = N;
    else       maxB = N + 1 - K, minB = 1;
    
    // 3. 出力.
    printf("%d\n", maxB - minB);
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = [int(x) for x in input().split()]
pe = [(i+1)/2 for i in p]

maxsum = -1
cul = sum(pe[0:k])
maxsum = cul
for i in range(1,n-k+1):
    cul = cul - pe[i-1] + pe[i+k-1]
    if cul > maxsum:
        maxsum = cul
print(maxsum)

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

int main(void){
    ll x;
    cin>>x;
    if (x == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i=sqrt(x*2)-2;i<sqrt(x*2)+2;i++){
        if (i*(i-1)>=x*2) {
            cout << i-1 << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0) cout << (b-a)/2 << endl;
    else{
        cout << min((a-1+1+b-1)/2,(n-b+1+n-a)/2) << endl;
    }
}


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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  a -= c;
  b -= d;
  a = abs(a);
  b = abs(b);
  ll g = __gcd(a,b);
  a /= g;
  b /= g;
  cout<<( (a+b-1)*g )<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct item {
	int value;
	int weight;
	item(int v = 0, int w = 0) {
		value = v; weight = w;
	}
};

const int MAX_W = 10010;
const int MAX_N = 101;

int main() {
	int N, W;
	cin >> N >> W;
	vector<item> items(N, 0);
	for(int i = 0; i < N; ++i) {
		int v, w;	
		cin >> v >> w;	
		items[i] = item(v, w);
	}

	int dp[MAX_W][MAX_N]; // ??????i?????§????????????????±?????????¨???????????????????????????w????????£???????????????????????§???
	fill_n((int *)dp, MAX_W*MAX_N, 0);	
	
	for(int w = 0; w <= W; ++w) {
		for(int i = (N - 1); i >= 0; --i) {
			if(w < items[i].weight) {
				dp[w][i] = dp[w][i + 1];
			} else {
				dp[w][i] = max(dp[w][i + 1], dp[w - items[i].weight][i + 1] + items[i].value);		
			}	
		}
	}

	cout << dp[W][0] << endl;
	return 0;
}

Measured memory_bytes: 5144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  int N;
  string S;
  cin>>N>>S;
  
  for(int i=0; i<S.size(); ++i){
    S.at(i)+=N;
    if(S.at(i)>=91) S.at(i)-=26;
  }
  
  co(S);
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> b(n+1);
    b[0]=1000000;
    b[n] = 1000000;
    int ans = 0;
    for (size_t i = 0; i < n-1; i++)
    {
        cin >> b[i + 1];
    }
    for (size_t i = 0; i < n-1; i++)
    {
        ans+=min(b[i],b[i+1]);
        /* code */
    }
    ans += min(b[n - 1], b[n]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 

def split_rc(rc):
    for i in range(1, len(rc)):
        yield rc[:i], rc[i:]

@memoize
def cost(rc):
    if len(rc) == 1:
        return 0
    return min(calc_cost(first, second) for first, second in split_rc(rc))

def calc_cost(first, second):
    return cost(first) + cost(second) + first[0][0] * first[-1][1] * second[-1][1]

n = int(input())
rc = tuple(tuple(map(int, input().split())) for _ in range(n))
print(cost(rc))

Measured memory_bytes: 8552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
  int W, H, x, y, r;
  int i;
  cin >> W >> H >> x >> y >> r;
  if (W < x + r || H < y + r) {
    cout << "No" << endl;
    return  0;
  }
  if (0 > x - r || 0 > y - r) {
    cout << "No" << endl;
    return  0;
  }
  cout << "Yes" << endl;
  return 0;

}



Measured memory_bytes: 3100
#include <stdio.h>
int main(void)
{
	int n, m;
    int a[51] = {0};
    int b[51] = {0};
    int ans[51] = {0};
    int i;
    scanf("%d %d", &n, &m);
    for (i = 1; i <= m; i++) {
        scanf("%d %d", &a[i], &b[i]);
        ans[a[i]]++;
        ans[b[i]]++;
    }
    for (i = 1; i <= n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> c(3);
    REP(i, 3) cin >> c[i];
    REP(i, 3) cout << c[i][i];
    cout << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
  int n,count = 0;
  cin >> n;
  
  for(int i = 1;i< 10;i++)
  {
    for(int j = 1; j < 10;j++)
    {
      if((i*j) == n)
      {
        count++;
      }
    }
  }
  
  if(count > 0)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }
}

Measured memory_bytes: 384
n,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(n)]

ans = float('inf')
for i in range(2**n):
    for j in range(2**n):
        where = [0]*n
        x,y = i,j
        b = 0
        while x > 0 or y > 0:
            where[b] += (x&1) + 2*(y&1)
            b += 1
            x,y = x >> 1 , y >> 1
        cnt = -30
        ABC = [0,0,0]
        for x,w in enumerate(where):
            if w == 0:continue
            ABC[w-1] += L[x]
            cnt += 10
        if 0 in ABC:continue
        ans = min(ans, cnt + abs(ABC[0] - A) + abs(ABC[1] - B) + abs(ABC[2] - C))
print(ans)


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

using namespace std;

const int N = 3010;

bitset <N> one, two;
int a, b, c, d, e, f;

int main() {
  cin >> a >> b >> c >> d >> e >> f;
  one[0] = two[0] = 1;

  for (int i = a; i <= f; i += a) {
    one |= one << i;
  }
  for (int i = b; i <= f; i += b) {
    one |= one << i;
  }
  for (int i = c; i <= f; i += c) {
    two |= two << i;
  }
  for (int i = d; i <= f; i += d) {
    two |= two << i;
  }

  int up = 0, down = a;
  for (int i = 1; i <= f; ++i) {
    if (!one[i]) continue;
    for (int j = 0; 100 * i + j <= f and j <= e * i; ++j) {
      if (!two[j]) continue;
      if (j * down > i * up) {
        up = j, down = i;
      }
    }
  }

  printf("%d %d\n", 100 * down + up, up);
  return 0;
}


Measured memory_bytes: 256