akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i = x;i<n;i++)
#define S(v) sort(v.begin(), v.end());
#define ff first
#define ss second



int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n, k = 0;
	cin>>n;
	string s;
	cin>>s;
	loop(i,0,n)if(s[i] == 'R')k++;
	ll ans = 0;
	loop(i,k,n)if(s[i] == 'R')ans++;
	cout<<min(ans, min(k, n-k));
}

Measured memory_bytes: 3728
a=input()
b=input()
c=input()
d=input()
e=input()
p=0
s=[a,b,c,d,e]
s = [int(n) for n in s]
l=10
m=[a[-1],b[-1],c[-1],d[-1],e[-1]]
for i in range(5):
    if int(m[i][-1])!=0 and l>int(m[i]):
        l=int(m[i][-1])
for i in range(5):
    while s[i]%10!=0:
        s[i]+=1
        p+=1
print(sum(s)-10+l)

Measured memory_bytes: 3064
n,m=map(int,input().split())
num=["-1"]*n
ans=0
for i in range(m):
    s,c=input().split()
    s=int(s)
    if s==1 and c=="0" and n!=1:
        ans=-1
    elif num[s-1] == "-1":
        num[s-1] = c
    else:
        if num[s-1] != c:
            ans=-1

if num[0] == "-1":
    if n>1:
        num[0] = "1"
    else:
        num[0] = "0"

for i in range(n):
    if num[i]=="-1":
        num[i]="0"

if ans==-1:
    print(ans)
else:
    print(int("".join(num)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll f(ll aa, ll bb) {
  ll a=min(aa,bb);
  ll b = max(aa,bb);
  if(a==b)
    return a;
  // b>a
  if(b%a==0)
    return 2*b-a;
    //return 2*a+f(a,b-a);
//    return a*(1+2*(b/a-1));
//    return 2*b-a;
  return 2*(b/a)*a+f(a,b%a);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n,x;
  cin>>n>>x;
  cout << n + f(n-x,x) << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;

ll M = 1e9 + 7;

ll power(ll a , ll n)
{
    unsigned long long int result=1,x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x = (x * x)%M;
        n=n/2;
    }
    return result%M;
}

#define nax 1000010
vector<ll> fact(nax);
vector<ll> inv(nax);
void pre()
{
    fact[0]=1;
    inv[0]=1;
    for(ll i=1;i<nax;i++)
    {
        fact[i]=(fact[i-1]*i)%M;
        inv[i]=power(ll(fact[i]),ll(M-2));
    }
}

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

    ll s;
    cin >> s;
    ll p = 1;
    ll ans = 0;
    while(1)
    {
        ll ka = s-3*p;
        if(ka < 0)
            break;
        ll m = ka + p - 1;
        ll k = p-1;
        ll kh =  (fact[m]*inv[m-k])%M;
        kh = (kh*inv[k])%M;
        ans += kh;
        ans%=M;
        p++;
    }
    cout << ans;
    return 0;
}


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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define found(u, val) u.find(val) != u.end()

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

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

    int n;
    cin >> n;
    int ar[n][3];
    for (int tr = 0; tr < n; tr++) {
        cin >> ar[tr][0] >> ar[tr][1] >> ar[tr][2];
    }

    int dp[n + 1][3];
    dp[n][0] = dp[n][1] = dp[n][2] = 0;

    for (int i = n - 1; i >= 0; i--) {
        dp[i][0] = ar[i][0] + max(dp[i + 1][1], dp[i + 1][2]);
        dp[i][1] = ar[i][1] + max(dp[i + 1][0], dp[i + 1][2]);
        dp[i][2] = ar[i][2] + max(dp[i + 1][1], dp[i + 1][0]);
    }
    int i = 0;
    cout << max(dp[0][0], max(dp[i][1], dp[i][2]));
}

Measured memory_bytes: 5960
N=int(input())
A=sorted(list(map(int, input().split())), reverse=True)
Bob=0
Alice=0
for i in range(len(A)):
  # print(i)
  if i == 0 or i%2==0:
    Alice+=A[i]
  else:
    Bob +=A[i]
print(Alice-Bob)


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

using namespace std ;

const int MAX = 1e5 + 10 ;

long long arr[MAX] ;
int n , m ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	long long cur = arr[0] / 2 ;
	for(int i = 1 ; i < n ; ++i)
	{
		long long now = arr[i] / 2ll ;
		cur = now / __gcd(now , cur) * cur ;
	}
	int cnt = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		long long now = arr[i] / 2ll ;
		if(((cur / now) & 1))
			cnt++ ;
	}
	if(cnt != n)
	{
		cur += cur ;
		cnt = 0 ;
		for(int i = 0 ; i < n ; ++i)
		{
			long long now = arr[i] / 2ll ;
			if(((cur / now) & 1))
				cnt++ ;
		}
		if(cnt != n)
			return cout<<0<<"\n" , 0 ;
	}
	return cout<<(m / cur + 1) / 2<<"\n" , 0 ;
}		

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll a[200100];
ll s[200100]={};
int main(void){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i!=0) s[i]=s[i-1];
    s[i]+=a[i];
    s[i]%=mod;
  }
  ll ans=0;
  for(int i=0;i<n-1;i++){
    ll sum=(s[n-1]-s[i]+mod)%mod;
    ans+=sum*a[i];
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

int main(){
  string str;
  while(getline(cin,str)){
    for(int i=0;i<26;i++){
      for(int j=0;j<str.size();j++){
	if(str[j]!=' ' && str[j]!='.'){
	  str[j]++;
	  if(str[j] > 'z')str[j] -= 26;
	}
      }
      if(str.find("the")!=string::npos){
	cout << str << endl;
	break;
      }else if(str.find("this")!=string::npos){
	cout << str << endl;
	break;
      }else if(str.find("that")!=string::npos){
	cout << str << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
  return 0;
}

Measured memory_bytes: 3040
MOD = 10**9 + 7


def main():
    # もらうDP
    H, W = (int(i) for i in input().split())
    c = [input() for i in range(H)]
    dp = [[0]*W for i in range(H)]

    dp[0][0] = 1
    for h in range(H):
        for w in range(W):
            le = 0
            up = 0
            if 0 <= w - 1 and c[h][w-1] != "#":
                le = dp[h][w-1]
            if 0 <= h - 1 and c[h-1][w] != "#":
                up = dp[h-1][w]
            dp[h][w] += le + up
            dp[h][w] %= MOD
    print(dp[-1][-1])


if __name__ == '__main__':
    main()


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;
    ll N, X, T;
    cin >> N >> X >> T;
    ll d = N / X;
    ll ans = d * T;
    if(d * X < N)
        ans += T;
    cout << ans << endl;

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3)) {
        cout << "Yes" << endl;
    } else if (s.at(0) == s.at(2) && s.at(2) != s.at(1) && s.at(1) == s.at(3)) {
        cout << "Yes" << endl;
    } else if (s.at(0) == s.at(3) && s.at(3) != s.at(1) && s.at(1) == s.at(2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/* Headers */

#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1e9 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> iii;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef priority_queue<pii, vector<pii>, greater<pii>> fila_prioridade;
typedef priority_queue<iii, vector<iii>, greater<iii>> fila_prioridade_grids;


#define INF 1000000000
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)


/* -------------- */

//NAME: Rally
//Source:  Atcoder Beginner Contest 156
//URL: https://atcoder.jp/contests/abc156/tasks/abc156_c
//TYPE: DP / Ad-hoc
/* Knowledge required:

*/


int coordenadas[105];
ll n,stamina;
ll resp = 10000000;

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

        cin >> n;

        for (int i = 0; i < n; i++) {
                cin >> coordenadas[i];
        }

        for (int p = 1; p <= 200; p++) {
                stamina = 0;
                for (int i = 0; i < n; i++) {
                        stamina += pow((coordenadas[i] - p), 2);
                }

                if (stamina < resp) {
                        resp = stamina;
                }
        }
        cout << resp << endl;



        return 0;
}


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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long int n,x,minimum,ans=0;
    cin>>n;
    cin>>minimum;
    for(long long int i=1;i<n;i++){
        cin>>x;
        if(min(minimum,x)==x){
            minimum=min(minimum,x);
        }else{ans++;}
    }
    cout<<n-ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define INF 1e9

struct P
{
	int cost, state;

	bool operator >(const P& p) const{
		return cost > p.cost;
	}
};

int main() {
	int n;
	while(cin >> n, n){
		vvi stage_times(n, vi(n + 1));
		REP(i, n){
			REP(j, n + 1){
				cin >> stage_times[i][j];
			}
		}

		vi G(1 << n, INF);

		priority_queue<P, vector<P>, greater<P>> que;
		que.push({0, (1 << n) -1});

		int res = -1;
		while(!que.empty()){
			P p = que.top(); que.pop();
			if(p.state == 0){
				res = p.cost;
				break;
			}
			 // LOG("cost %d state %d\n", p.cost, p.state);

			REP(i, n){
				if(p.state & (1 << i)){//そのステージへ行ったことがない
					priority_queue<int, vi, greater<int>> costs;
					//装備を使わない
					costs.push(stage_times[i][0]);

					//なにか装備を使う
					REP(j, n){
						if (p.state & (1 << j)) continue; //そのステージをクリアしてないなら装備は使えない
						// LOG("can use %d\n", j);
						costs.push(stage_times[i][j + 1]);
					}

					int next_state = p.state & ~(1 << i);
					int next_cost = p.cost + costs.top();
					if (G[next_state] > next_cost){
						G[next_state] = next_cost;
						que.push({next_cost, next_state});
					}
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 2128
int main()
{
	int d;
	int r;
	double f;

	int a, b;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = 1.0*a / b;

	printf("%d %d %.5lf", d, r, f);

	return 0;

	
}




Measured memory_bytes: 2132
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var List = new List<String>();

            while (true)
            {
                String s = Console.ReadLine();
                String[] strList = s.Split();

                int x = int.Parse(strList[0]);
                int y = int.Parse(strList[1]);

                if (x == 0 && y == 0)
                {
                    break;
                }

                if (x < y)
                {
                    List.Add(x + " " + y);
                }else
                {
                    List.Add(y + " " + x);
                }
            }

            for (int i = 0; i < List.Count(); i++)
            {
                Console.WriteLine(List[i]);
            }
        }
    }
}



Measured memory_bytes: 14224
# -*- coding: utf-8 -*-
# D

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
score = [R, S, P]

# Kのあまりごとに独立して計算する
ans = 0
num = N // K + 1


def vic_sol(s):
    if s == 'r':
        return 2
    if s == 's':
        return 0
    if s == 'p':
        return 1


def ret_score(mine, i, mod, past_rsp):
    sol = vic_sol(T[i * K + mod])
    if (mine == sol) and (sol != past_rsp):
        return score[sol]
    else:
        return 0


for mod in range(K):
    dp = [[0] * 3 for _ in range(num+2)]
    ret = 0
    # 0: R, 1: S, 2: P
    for i in range(1, num+1):
        if (i-1) * K + mod >= N:
            break
        # print(i, num, (i-1) * K + mod)
        dp[i][0] = max(dp[i-1][1] + ret_score(0, i-1, mod, 1), dp[i-1][2] + ret_score(0, i-1, mod, 2))
        dp[i][1] = max(dp[i-1][0] + ret_score(1, i-1, mod, 0), dp[i-1][2] + ret_score(1, i-1, mod, 2))
        dp[i][2] = max(dp[i-1][0] + ret_score(2, i-1, mod, 0), dp[i-1][1] + ret_score(2, i-1, mod, 1))

        if mod == 0:
            dp[i][0] = max(dp[i][0], dp[i - 1][0] + ret_score(0, i - 1, mod, 0))
            dp[i][1] = max(dp[i][1], dp[i - 1][1] + ret_score(1, i - 1, mod, 1))
            dp[i][2] = max(dp[i][2], dp[i - 1][2] + ret_score(2, i - 1, mod, 2))

        ret = max(ret, dp[i][0], dp[i][1], dp[i][2])
    # print(dp)
    ans += ret

print(ans)


Measured memory_bytes: 111156
n = int(input())
words = [sorted(input()) for _ in range(n)]
sorted_words = sorted(words)

result = 0
sorted_words_dup = sorted_words[:]
while sorted_words_dup:
    same_cnt = 1
    word = sorted_words_dup.pop()
    while 0 < len(sorted_words_dup) and sorted_words_dup[-1] == word:
        sorted_words_dup.pop()
        same_cnt += 1
    result += same_cnt*(same_cnt-1)//2

print(result)


Measured memory_bytes: 25796
//「1文字指定される→辺を移動する」を交互に繰り返すゲームと同値。
//その場合、Aとしか繋がってない頂点、Bとしか繋がってない頂点、何とも繋がってない頂点に行くと、次のターンにゲームオーバーなので、
//A,B両方と繋がっている頂点以外は削除しても解に影響しないことが分かる。そのような操作を繰り返していき、頂点が残らなければ
//No. 頂点が残った場合は、「どの頂点もA,B両方と繋がっている」ので、何処にいても必ず移動できる。よってYes.
#include <iostream>
#include <string>
#include <queue>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
string s;
vector<int> et[200000];
int da[200000], db[200000];
bool erased[200000];

int main() {
	int i, j;
	
	cin >> n >> m >> s;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	rep(i, n) {
		rep(j, et[i].size()) {
			int v = et[i][j];
			if (s[v] == 'A') da[i]++;
			else db[i]++;
		}
	}
	
	queue<int> que;
	rep(i, n) if (da[i] == 0 || db[i] == 0) { erased[i] = true; que.push(i); }
	while (!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, et[v].size()) {
			int nv = et[v][i];
			if (s[v] == 'A') { da[nv]--; }
			if (s[v] == 'B') { db[nv]--; }
			if ((da[nv] == 0 || db[nv] == 0) && !erased[nv]) {
				erased[nv] = true;
				que.push(nv);
			}
		}
	}
	
	rep(i, n) {
		if (!erased[i]) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){

    int n, a, b; cin >> n >> a >> b;
    if(n == 2) cout << "Borys" << endl;
    else{
        int t = a - b;
        if(t < 0) t = -t;
        if(t % 2 == 1) cout << "Borys" << endl;
        else cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
l = [int(x) for x in list(str(input()))]


def manysum(n):
    if len(n) == 1:
        return n[0]
    a = n[0] * (2 ** (len(n) - 2)) + manysum(n[1:])
    n[1] += 10 * n[0]
    b = manysum(n[1:])

    return a + b

print(manysum(l))

Measured memory_bytes: 3060
n = int(input())
arr = list(map(int,input().split()))

arr2 = []

for i in range(n):
	arr2.append([arr[i],i+1])

arr2.sort(key=lambda x:x[0])

ans =[]

for j in range(n):
	ans.append(arr2[j][1])

arrr = ' '.join(str(k) for k in ans)
print(arrr)

Measured memory_bytes: 28384
n,m,k = map(int,input().split())
mod = 998244353
f = [1]*(n+1)
revf = [1]*(n+1)
for i in range(2,n+1):
    f[i] = f[i-1] *i%mod
revf[n] = pow(f[n],mod-2,mod)
for i in range(n-1,0,-1):
    revf[i] = revf[i+1]*(i+1)%mod
def C(x,y):return f[x]*revf[y]*revf[x-y]%mod
ans = 0
for i in range(k+1):
    ans += m*pow(m-1,n-i-1,mod)*C(n-1,i)
    ans %= mod
print(ans)


Measured memory_bytes: 24712
n, x = map(int, input().split())
a = list(map(int, input().split()))

# array size nxn filled with zeroes
minrange = [[0 for j in range(n)] for i in range(n)]
for r in range(n):
    for l in range(r):
        minrange[l][r] = min(minrange[l][r-1], a[r])
    minrange[r][r] = a[r]

res = int(1e18) # 10^18 is basically infinity
for k in range(n):
    cur = k*x
    for i in range(n):
        if i-k >= 0:
            cur += minrange[i-k][i]
        else:
            cur += min(minrange[0][i], minrange[i-k+n][n-1])
    res = min(res, cur)

print(res)


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int N, M; cin >> N >> M;
    vs A(N), B(M);
    REP(i, N) cin >> A[i];
    REP(i, M) cin >> B[i];

    for(int i = 0; i <= N-M; i++)
    {
        for(int j = 0; j <= N-M; j++)
        {
            bool match = true; 
            REP(k, M)
            {
                REP(l, M)
                {
                    if(A[i+k][j+l] != B[k][l]) match = false;
                }
            }
            if(match)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,h,area;
    scanf("%d %d %d",&a,&b,&h);
    area=(a+b)*h/2;
    cout << area << "\n";
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=5005;
char mc='z',s[N<<1];
int n,k,f[N<<1],ma,p;

bool compare(int l,int r){
	for(;s[l]==s[r];l++,r++) ;
	return s[l]<s[r];
}

signed main(){
	read(n,k);k=min(k,15);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) s[n*2-i+1]=s[i];
	for(int i=1;i<=n;i++) s[i]<mc?mc=s[i]:1;
	for(int i=n*2;i;i--) f[i]=s[i]==mc?f[i+1]+1:0,ma=f[i]>ma?f[i]:ma;
	int rest=max(n-(ma<<k-1),0);
	for(int i=1;i<=n;i++) if(f[i]==ma&&(!p||compare(i+ma,p))) p=i+ma;
//	write(ma);return 0;
	for(int i=1;i<=n-rest;i++) putchar(mc);
	for(int i=0;i<rest;i++) putchar(s[p+i]);
}

Measured memory_bytes: 3716
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define int long long

#define NUM 1000000007

struct _chunk {
	int name;
	int nextNum;
	vector<int> next;
};

int factorial(int num1, int num2){
    int sum = 1;
    for (int i = num1 + 1; i <= num1 + num2; ++i)
    {
        sum *= i;
    }

    for (int i = num2; i >= 1; --i) {
    	sum /= i;
    }
    return sum;
}

signed main(void) {
  int N, D;
  cin >> N >> D;
  int A[N][D];
  for (int i=0; i<N; i++) {
  	for (int j=0; j<D; j++) {
  		cin >> A[i][j];
  	}
  }

  int ans = 0;

  for (int i=0; i<N; i++) {
  	for (int j=i+1; j<N; j++) {
  		float dist = 0;
  		for (int k=0; k<D; k++) {
  			dist += (A[i][k] - A[j][k])*(A[i][k] - A[j][k]);
  		}
  		dist = sqrt(dist);
  		if(ceil(dist) == floor(dist)) {
  			ans++;
  		}
  	}
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int>;
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
const int MXV = 25;
string s[MXV];

int d[MXV][MXV];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int bfs(int h, int w, int a, int b)
{
    int mx = 0;
    queue<PII> q;
    q.push({a, b});
    memset(d, -1, sizeof(d));
    d[a][b] = 0;
    while(!q.empty())
    {
        PII k = q.front(); q.pop();
        for(int i = 0, x, y; i < 4; ++i)
        {
            x = k.first + dx[i];
            y = k.second + dy[i];
            if(x < 0 || x >= h || y < 0 || y >= w)
            {
                continue;
            }
            if(s[x][y] == '.' && d[x][y] == -1)
            {
                d[x][y] = d[k.first][k.second] + 1;
                mx = max(mx, d[x][y]);
                q.push({x, y});
            }
        }
    }
    return mx;
}

int main()
{
    IOS;
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; ++i)
    {
        cin >> s[i];
    }
    int ans = 0;
    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            if(s[i][j] == '#')
            {
                continue;
            }
            ans = max(ans, bfs(h, w, i, j));
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

int main(){
	int k,x;

	cin >> k >> x;

	for(int i=x-k+1;i<=x+k-1;i++){
		cout << i << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/////////////////////////////////////
#define int long long  
#define lld long long double
#define mod 1000000007
#define pb push_back
#define ull unsigned long long
#define forn(i,n) for(int i=0;i<(int)n) ;i++)
#define DEBUG(a) cerr << #a << " = " << a << endl;
#define DEBUG_ARRAY(a,n)  for(long long i=0;i<(int)n;i++) cerr << a[i]<< "  ";cout<<endl;
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)<(b))?(a):(b)
//#define _DEBUG

using namespace std;

/////////////////////////////////////
void solve(){
   int n;
  cin>>n;
  int ok = ( n>=1 && n<=81),ok1= 0 ;
  
  for(int i =1 ; i<=9 ;i++){
    for(int j = 1 ;j<=9;j++){
      if(i*j==n) ok1 = 1;
    }
  } 
  if(ok&&ok1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}
int32_t main() {
    /////////////////////////////////////
    #ifdef _DEBUG
	int tt = (int) clock();
    #endif
    /////////////////////////////////////
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /////////////////////////////////////
  
    solve();
    /////////////////////////////////////
    #ifdef _DEBUG
        cerr << "TIME = " << (double)(clock() - tt) / CLOCKS_PER_SEC << endl;
    #endif
    /////////////////////////////////////
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> g[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> s;
    s.push(r);
    color[r] = c;
    while (!s.empty()) {
        int u = s.top(); s.pop();
        for (int i = 0; i < g[u].size(); i++) {
            int v = g[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                s.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        g[s].push_back(t);
        g[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}



Measured memory_bytes: 8952
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int p[n];
  for(int i=0; i < n; i++){
    scanf("%d",&p[i]);
  }
  
  int max = p[0];
  for(int j=0; j < n; j++){
    if(max < p[j]) max = p[j];
  }
  int sum = 0;
  for(int k=0; k < n; k++){
    sum += p[k];
  }
  printf("%d",sum - (max/2));
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.nextLine());

		String s = (X == 3 || X == 5 || X == 7) ? "YES" : "NO";
		System.out.println(s);
	}
}

Measured memory_bytes: 19796
#include <cstdio>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

typedef complex<double> P;
typedef const P &rP;

double pi2;

vector<double> intrarg(rP s, double r, rP p, rP q){
	vector<double> ret;
	P v = q - p;
	P w = p - s;
	double a = norm(v);
	double b = real(v) * real(w) + imag(v) * imag(w);
	double c = norm(w) - r * r;
	double D = b * b - a * c;
	double t;
	if(D >= 0.0){
		D = sqrt(D);
		for(double sgn = -1.0; sgn < 2.0; sgn += 2.0){
			t = (-b + sgn * D) / a;
			if(t > 0.0 && t < 1.0){
				ret.push_back(arg(w + t * v));
			}
		}
	}
	return ret;
}

double difarg(double a, double b){
	a -= b;
	while(a < 0.0) a += pi2;
	while(a >= pi2) a -= pi2;
	return a;
}

int main(){
	pi2 = acos(-1.0) * 2.0;
	
	int m, n;
	double x, y;
	while(scanf("%d%d", &m, &n), m){
		vector<P> p(m + 1), q(n + 1);
		for(int i = 0; i < m; ++i){
			scanf("%lf%lf", &x, &y);
			p[i] = P(x, y);
		}
		p[m] = p[0];
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf", &x, &y);
			q[i] = P(x, y);
		}
		q[n] = q[0];
		scanf("%lf%lf", &x, &y);
		P c(x, y);

		double ans = pi2;

		for(int i = 0; i < n; ++i){
			double r1 = abs(q[i] - c);
			double base1 = arg(q[i] - c);
			for(int j = 0; j < m; ++j){
				double r2 = abs(p[j] - c);
				double base2 = arg(p[j] - c);

				vector<double> ret = intrarg(c, r1, p[j], p[j+1]);
				for(int k = 0; k < ret.size(); ++k){
					ans = min(ans, difarg(ret[k], base1));
				}

				ret = intrarg(c, r2, q[i], q[i+1]);
				for(int k = 0; k < ret.size(); ++k){
					ans = min(ans, difarg(base2, ret[k]));
				}
			}
		}

		printf("%.9f\n", ans / pi2 * 360.0);
	}
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <stdbool.h>

int main() {
	int N, M, s[5], c[5];
	scanf("%d%d",&N,&M);
	for (int i = 0; i < M;i++) {
		scanf("%d%d",&s[i],&c[i]);
	}
	bool t[5] = {false};
	int ans[3] = {10,10,10};

	for (int i = 1; i <= N;i++) {
		for (int j = 1; j <= M;j++) {
			if (s[j-1]==i) {
				if (t[i-1]==false) {
					ans[i-1] = c[j-1];
					t[i-1] = true;
				}
				else if(ans[i-1]!=c[j-1]){
					printf("-1");
					return 0;
				}
			}
		}
	}
	for (int i = 0; i < 3;i++) {
		if (ans[i]==10&&i==0&&N!=1) {
			ans[i] = 1;
		}
		else if(ans[i]==10){
			ans[i] = 0;
		}
	}
	if (ans[0]==0&&N>1) {
		printf("-1");
		return 0;
	}
	for (int i = 0; i < N;i++) {
		printf("%d",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
x,k,d=map(int,input().split())
if x>=0:
    a = x % d
    b = x%d-d #負の値
    if a<abs(b):goal=a
    else:goal=b
    if x-k*d>=a:
        res=x-(k*d)
    else:
        rem=k-(x-a)//d
        if rem%2==0:
            res=a
        else:
            res=abs(b)
else:
    a=-((-x)%d)
    b=a+d
    if abs(a)>b:goal=b
    else:goal=a
    if abs(x)-k*d>=-a:
        res=abs(x+(k*d))
    else:
        rem=k-(abs(x-a))//d
        if rem%2==0:
            res=abs(a)
        else:
            res=b
print(res)

Measured memory_bytes: 61996
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>

using namespace std;


int main(){
   int a,b;
   int sum[1100]={0};
   cin>>a>>b;
   bool flag=false;
   sum[1]=1;
   for(int i=2;i<1000;i++){
      if(flag)break;
      for(int j=1;j<i+1;j++){
         sum[i]+=j;
         if(sum[i-1]-a==sum[i]-b){
            cout<<sum[i-1]-a<<endl;
            flag=true;
            break;
         }
      }
   }
  
   
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i=2; i<n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
n = int(input())
a = [int(_) for _ in input().split()]
w = [int(_) for _ in input().split()]

if sum(a) == n or sum(a) == 0:
    print(0)
    quit()

lia = []
lib = []
for i in range(n):
    if a[i] == 0:
        lia.append(w[i])
    else:
        lib.append(w[i])

print(min(lia)+min(lib))


Measured memory_bytes: 5604
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readLongList()
    val a1 = aList.reduceIndexed { i, acc, v -> acc + if (i % 2 == 0) v else -v }
    val ansArray = LongArray(n)
    ansArray[0] = a1
    for (i in 1 until n) {
        ansArray[i] = 2 * (aList[i - 1] - ansArray[i - 1] / 2)
    }
    out.println(ansArray.joinToString(" "))
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 63720
H, W = map(int, input().split())
coins = []
for i in range(H):
    a = list(map(int, input().split()))
    coins.append(a)

out = []


def move(x1, y1, x2, y2):
    if 0 <= x2 < H and 0 <= y2 < W:
        coins[x1][y1] -= 1
        coins[x2][y2] += 1
        out.append((x1 + 1, y1 + 1, x2 + 1, y2 + 1))


for i in range(0, H, 2):
    for j in range(W):
        if coins[i][j] % 2:
            if j < W - 1:
                move(i, j, i, j + 1)
            else:
                move(i, j, i + 1, j)
    for j in range(W - 1, -1, -1):
        if i < H - 1 and coins[i + 1][j] % 2:
            if j > 0:
                move(i + 1, j, i + 1, j - 1)
            else:
                move(i + 1, j, i + 2, j)

print(len(out))
for c in out:
    print(*c)


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

int main(void){
	int n;
	int P,W,G,Y;
	P = W = G = Y = 0;
	cin >> n;
	char arare;
	for(int i=0;i<n;i++){
		cin >> arare;
		
		switch(arare){
			case 'G':
				G = 1;
				break;
			case 'Y':
				Y = 1;
				break;
			case 'W':
				W = 1;
				break;
			case 'P':
				P = 1;
				break;
			default:
				break;
		}
	}
	if(P && W && G && Y){
		cout << "Four" << endl;
	}else{
		cout << "Three" << endl;
	}
	
	return 0;
}
	

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int n,k;
  cin>>n>>k;
  vl x(n);
  rep(i,n) cin>>x[i];
  
  int ans=1000000000;
  rep(i,n-k+1){
    int xr = x[n-1-i],xl=x[n-k-i]; 
    ans =min(ans, min( abs(xr,0)+abs(xl,xr)  , abs(xl,0)+abs(xl,xr)   ) );
     
  
  }
  cout<<ans<<endl;
}





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

int main()
{
 vector<int>v;
 int a,b,c,k;
 cin >> a >> b >> c >> k;
 v.push_back(a);
 v.push_back(b);
 v.push_back(c);
 int sum = 0;
 while(k--)
 {
     sort(v.begin(),v.end());
     v[2]*=2;

 }

 sum = v[0] + v[1] + v[2];
 cout << sum << endl;


}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{ 
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str = ReadLine();
        var s = str.IndexOf('C');
        var ss = str.LastIndexOf('F');
        if (s < 0 || ss < 0) WriteLine("No");
        else if (s > ss) WriteLine("No");
        else WriteLine("Yes");
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define PB push_back
#define MP make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
const ld PI = 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);IN(ll,K);AIN(ll,H,N);
  ll dp[N];
  REP(i,N){
    dp[i] = INF;
  }
  dp[0] = 0;
  REP(i,N){
    REP(j,K+1){
      if(i-j >= 0 && j != 0){
        chmin(dp[i], dp[i-j]+abs(H[i] - H[i-j]));
      }
    }
  }
  OUT(dp[N-1]);
}

Measured memory_bytes: 1792
#include<iostream>
#include<stack>
#include<queue>
#include<math.h>
#include<algorithm>
#include <iomanip>
using namespace std;
#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))
#define N_MAX 201
#define L_MAX 10001
#define ll long long


//??????????????¨??????
int N,K,T,U,V,L;
int D[N_MAX];

//????§???????index(m)?????¨???????????°??£???????????????
bool run[L_MAX];

//?????¨???????????????????????£????????????
int carrot=0;

//???????????????????????°???????????¨???m?¶??????§?????????
int lestRun=0;

//?¬???????????????????D???????????????
int nextCarrot=0;

//????§??????????????????????????????§??????
int meter=0;

int main() {
	//??\?????¨?????????
	cin>>N>>K>>T>>U>>V>>L;
	rep(i,N)cin>>D[i];
	rep(i,L)run[i]=false;

	//??????????????????????????????
	while(meter<L){
		if(D[nextCarrot]==meter){
			//???????????????
			carrot++;nextCarrot++;
			
			//??¢?????????????????????????£????
			if(carrot>K){lestRun=T*V;carrot--;}
		}

		//??????????¶????????????£???????£???????????????????
		if(lestRun==0 && carrot>0){carrot--;lestRun+=T*V;}

		//????±???°????????¶????????£???????????°??£?????????????????????
		if(lestRun>0){run[meter]=true;lestRun--;}

		//??????
		meter++;
	}
	//????±???°??£????????¢
	int runDist=0;
	rep(i,L)if(run[i])runDist++;

	//??????
	cout<< setprecision(10)<< (double)runDist/V + (double)(L-runDist)/U <<endl;

	//???????????°
	//rep(i,L)cout<<i<<" : "<<run[i]<<endl;

	//cin>>N;
	return 0;
}

Measured memory_bytes: 3272
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N,M;
int A,B,C;
int sum, ans;
string S;

int main() {
	cin >> A >> B;

	if (A <= B) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;

	}


	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
  //場合分けして格納
}

void inorder(Node u){
  if(u == NIL)return ;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}
void preorder(Node u){
  if(u == NIL)return ;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25132
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 lli power(lli x,lli y,lli p)
{
  lli res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    //y must be even now
    y=y>>1; //y=y/2
    x=(x*x)%p;
  }
  return res;
}
 
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b)
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b)
{
  if (a < b)
    return a;
  return b;
}
using namespace std;

int main()
{  
    kira;
    //freopen("input.txt","r",stdin);
   lli n,q,a,b,p,x;
   cin>>n>>q;
   lli s[200005];
   lli ss[200005]={0};
   s[1]=-1;
   for(lli i=0;i<n-1;i++)
   {
    cin>>a>>b;
    s[b]=a;
   }
   for(lli i=0;i<q;i++)
   {
    cin>>p>>x;
    
    ss[p]+=x;
   }
   lli sss[200005];
   fill(sss,sss+200005,-1);
  lli j,pp=0;
   for(lli i=1;i<=n;i++)
   { j=i;
   pp=0;
    while(1)
    {  
      
      if(j==-1)
        break;
        if(sss[j]!=-1)
      {
      	pp+=sss[j];
      	break;
      }
        pp+=ss[j];
      j=s[j];
    }
    sss[i]=pp;
    cout<<pp<<" ";
   }
}

Measured memory_bytes: 7168
#include <iostream>
using namespace std;
int int_sort(const void*a,const void *b) {
    return *(long long int *) b - *(long long int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}
int main() {
  int a,b,c;
  cin >>a>>b;

  cout<<a+b/2;
  return 0;
}

Measured memory_bytes: 256
from math import gcd

def gcd3(a,b,c):
    return(gcd(gcd(a,b),c))

k = int(input())

print(sum([gcd3(a,b,c) for a in range(1,k+1)
 for b in range(1,k+1)
 for c in range(1,k+1)]))

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

int main()
{
    int S;
    cin>>S;
    int a,b;
    a=S/100;
    b=S%100;
    bool a1,b1;
    if(a>=1&&a<=12){a1=1;}
    else{a1=0;}
    if(b>=1&&b<=12){b1=1;}
    else{b1=0;}
    if(a1==1&&b1==1){cout<<"AMBIGUOUS"<<endl;}
    if(a1==0&&b1==0){cout<<"NA"<<endl;}
    if(a1==0&&b1==1){cout<<"YYMM"<<endl;}
    if(a1==1&&b1==0){cout<<"MMYY"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int main(){
    ll n; cin >> n;
    ll ans = 0;

    for(ll i = 1; i*i < n ; i++){
        if(n%i == 0 and (n/i) - i >= 2) ans += (n/i) -1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	int n,m;
    cin>>n>>m;
    int ans=n*(n-1)+m*(m-1);
    ans/=2;
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n,p = map(int,input().split())
x = [int(i) for i in input().split()]
odd = 0
ans = 0
ans_tmp = 0
for i in x:
  if i%2:
    odd += 1

ans += 2**(n-odd)
tmp = odd//2
if p:#p==1のとき
  if odd:
    for i in range(tmp):
      ans_tmp += cmb(odd,i*2+1)
else:#p==0のとき
  if odd:
    tmp += 1
    for i in range(tmp):
      ans_tmp += cmb(odd,(i*2))
  else:
    ans_tmp = 1

ans *= ans_tmp
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int, pair<string, int>> SP;
#define mp(a, b) make_pair(a, b)

bool comp(SP lhs, SP rhs) {
  if (lhs.second.first != rhs.second.first) {
    // return lhs.second.first.compare(rhs.second.first);
    return lhs.second.first <= rhs.second.first;
  } else {
    //    return lhs.second.first.compare(rhs.second.first);
    return lhs.second.second > rhs.second.second;
  }
}

int main(int argc, char const *argv[]) {
  int n;

  cin >> n;

  vector<SP> spv;
  string city;
  int score;
  for (int i = 0; i < n; i++) {
    cin >> city;
    cin >> score;
    spv.push_back(mp(i + 1, mp(city, score)));
  }

  //  for (auto spvi = spv.begin(); spvi != spv.end(); spvi++) {
  //    cout << spvi->first << endl;
  //    cout << spvi->second.first << endl;
  //    cout << spvi->second.second << endl;
  //  }

  sort(spv.begin(), spv.end(), comp);

  for (auto spvi = spv.begin(); spvi != spv.end(); spvi++) {
    cout << spvi->first << endl;
  }

  return 0;
}


Measured memory_bytes: 256
X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
def solve(P):
    count = 0
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                if (A[i]+B[j]+C[k]) < P:
                    break
                count += 1
                if count >= K:
                    return True
    return False

maxa = A[0]+B[0]+C[0]+1
mina = 0

while maxa -mina > 1:
    mid = (maxa+mina)//2
    if solve(mid):
        mina = mid
    else:
        maxa = mid
ans = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (A[i]+B[j]+C[k]) < mina:
                break
            ans.append(A[i]+B[j]+C[k])

ans.sort(reverse=1)
for i in range(K):
    print(ans[i])


Measured memory_bytes: 188060