akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;
typedef long long LL;
int main() {
    int n,k;LL ans=0;
    scanf("%d%d",&n,&k);
    if (!k) ans=1LL*n*n;
    else {
        F2(mod, k+1, n) {
            int x=n/mod;
            ans += 1LL*x*(mod-1-k+1);
            int temp=n%mod;
            if (temp>=k) ans += temp-k+1;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

const int maxn = 1e6+6;
int n, a[maxn];
vector<int> divs[maxn];

bool comp[maxn];

int cnt[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    int gc = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        gc = __gcd(gc,a[i]);
    }
    for (int i = 1; i <= 1000000; i++) {
        divs[i].reserve(30);
    }
    for (int i = 2; i <= 1000000; i++) {
        if (!comp[i]) {
            for (int j = i; j <= 1000000; j += i) {
                divs[j].push_back(i);
                if (j > i) comp[i] = true;
            }
        }
    }
    bool isPairwise = true;
    for (int i = 0; i < n; i++) {
        for (auto d: divs[a[i]]) {
            if (++cnt[d] > 1) {
                isPairwise = false;
                break;
            }
        }
    }

    if (isPairwise) {
        cout << "pairwise coprime\n";
    }
    else if (gc == 1) {
        cout << "setwise coprime\n";
    }
    else {
        cout << "not coprime\n";
    }
}


Measured memory_bytes: 193948
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],b[100001],ans,zero=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n+1;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		if(b[i]>a[i])
		{
			ans+=min(a[i]+a[i+1],b[i]);
			a[i+1]=max(zero,a[i]+a[i+1]-b[i]);
		}
		else
			ans+=b[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
from sys import stdin
import heapq
hq = []  

NM = input()
NM = NM.split()
N = int(NM[0])
M = int(NM[1])

hq = []
AB = {}
for i in range(N):
  temp = input()
  temp = temp.split()
  AB[int(temp[0])] = int(temp[1])
  heapq.heappush(hq, (int(temp[0]), int(temp[1])))

cost = 0
amount = 0
for i in range(N):
  temp = heapq.heappop(hq)
  if amount + temp[1] < M:
    amount += temp[1]
    cost += temp[0]*temp[1]
  else:
    temp1 = M - amount
    cost += temp[0]*temp1
    break
    
print(cost)


Measured memory_bytes: 29616
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<pair<ll, ll>> p(n);
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    p[i] = {a, b};
  }
  sort(p.begin(), p.end(), [](pair<ll, ll> p1, pair<ll, ll> p2) {
      return p1.first + p1.second > p2.first + p2.second;
      });
  ll result = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      result += p[i].first;
    } else {
      result -= p[i].second;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <map>

typedef long long ll;

ll N,M;
ll a;

std::map<ll,ll> hash;

int main(){
        scanf("%lld %lld",&N,&M);

        ll sum = 0;
        hash[0] = 1;
        for(int i = 0; i < N; i++){
                scanf("%lld",&a);
                sum += a;
                hash[sum % M]++;
        }

        ll ans = 0;
        for(auto it = hash.begin(); it != hash.end(); it++){
                ans += (it->second >= 2) ? it->second*(it->second -1)/2 : 0;
        }

        printf("%lld\n",ans);
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int k, a,b, ans = 0;
	cin >>k >>a >>b;
	
	rep2(i, 1, 1000){
		if(i * k >= a && i*k <=b){
			puts("OK"); return 0;
		}
	}
	
	cout << "NG\n";
	return 0;
}


Measured memory_bytes: 3640
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<Long> v(n);
  fore(i, 0, n) cin >> v[i];
  Long ans = 0;
  int maxi = 0;
  fore(i, 0, n) {
    if (v[i] < maxi)
      ans += (maxi - v[i]);
    else
      maxi = v[i];
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4752
N = int(input())
S = {}
for i in range(N):
    j = input()
    if((j in S) == False):
        S[j] = 1
    else:
        S[j] += 1
M = int(input())
T = {}
for i in range(M):
    j = input()
    if((j in T) == False):
        T[j] = 1
    else:
        T[j] += 1
ans = 0
for key,value in S.items():
    if(key in T):
        ans = max(ans,value - T[key])
    else:
        ans = max(ans,value)
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 5005;
int n, a[N], dp[N][N][2], pos[N], A, B;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> A >> B;
	fw (i, 0, n) {
		cin >> a[i], a[i]--;
		pos[a[i]] = i;
	}
	memset(dp, 63, sizeof dp);
	dp[0][0][0] = 0;
	fw (i, 0, n) fw (j, 0, n + 1) fw (k, 0, 2) {
		//i - 1 was in segment j - 1...j, including j - 1. Was j - 1 filled?
		dp[i][j + 1][0] = min(dp[i][j + 1][0], dp[i][j][k]);
		if (pos[i] == j - 1) {
			int cost = 0;
			if (k) cost = A;
			dp[i + 1][j][1] = min(dp[i + 1][j][1], dp[i][j][k] + cost);
		} else if (pos[i] >= j) {
			dp[i + 1][j][1] = min(dp[i + 1][j][1], dp[i][j][k] + B);
		} else if (pos[i] < j - 1) {
			dp[i + 1][j][1] = min(dp[i + 1][j][1], dp[i][j][k] + A);
		}
	}
	int ans = infll;
	fw (j, 0, n + 1) fw (k, 0, 2) ans = min(ans, dp[n][j][k]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 391808
#include<cstdio>
#include<algorithm>
#include<cstring>

#define MIN(x,y) ((x<y)? x:y)
#define INF (100000000)

using namespace std;

int date[2][105][105];
int answer[105];//最短距離
int subdate[105];//0...最短が決定,定数...次行ける,INF...次行けない
int n,m;
int a,b,cost,time;
int k;
int p,q,r;

int main()
{
	while(true)
	{
		scanf("%d%d",&n,&m);
		for(int j=0;j<=m;j++)for(k=0;k<=m;k++)date[0][j][k]=date[1][j][k]=INF;
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)
		{
			scanf("%d%d%d%d",&a,&b,&cost,&time);
			date[0][a][b]=date[0][b][a]=cost;
			date[1][a][b]=date[1][b][a]=time;
		}
		scanf("%d",&k);
		for(int i=0;i<k;i++)
		{
			scanf("%d%d%d",&p,&q,&r);
			fill(subdate,subdate+105,INF);
			answer[104]=p;
			answer[p]=0;
			subdate[p]=0;
			while(true)
			{
				answer[101]=-1;
				//最後に更新した点から行けるところを更新
				//そして、最短経路が決まっているところから
				//後ひと駅で行ける場所の中で最短を最短経路として決定する
				answer[103]=INF;
				for(int j=1;j<=m;j++)
				{
					subdate[j]=MIN(subdate[j],answer[answer[104]]+date[r][answer[104]][j]);
				}
				for(int j=1;j<=m;j++)
				{
					if(subdate[j]!=0&&answer[103]>subdate[j])
					{
						answer[103]=subdate[j];
						answer[104]=j;
					}
				}
				if(answer[103]==INF)break;
				answer[answer[104]]=answer[103];
				subdate[answer[104]]=0;
			}
			printf("%d\n",answer[q]);
		}
	}
	return 0;
}

Measured memory_bytes: 1112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
struct node
{
    ll num,pri;
}a[100005];
bool cmp(node x,node y)
{
    return x.pri<y.pri;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i].pri>>a[i].num;
    sort(a+1,a+1+n,cmp);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i].num<=m)
        {
            m-=a[i].num;
            sum+=a[i].num*a[i].pri;
        }
        else
        {
            sum+=m*a[i].pri;
            m=0;
        }
        if(m==0)
            break;
    }
    cout<<sum;
    return 0;
}

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

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

ll	get_key(string str)
{
	ll	key;

	key = 0;
	rep(i, str.size())
	{
		key *= 5;
		key += get_char(str.at(i));
	}
	return (key);
}

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

	int					n;
	bitset<250000000>	bs;

	cin >> n;
	rep(i, n)
	{
		string	com;
		string	str;
		ll		key;

		cin >> com >> str;
		key = get_key(str);
		if (com.at(0) == 'i')
			bs.set(key);
		else
		{
			if (bs.test(key))
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
}



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

using namespace std;
typedef long long ll;

const int N=200005,M=2005,L=4010,P=1e9+7,K=8000;
const ll lim_mod=P;
int n,cl[L][L],m,fac[K+5],ifac[K+5];
ll dp[L][L],ans;

inline int power(int a,int t){int r=1;while(t){if(t&1)r=(ll)r*a%P;a=(ll)a*a%P;t>>=1;}return r;}
inline int C(int n,int m){return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}

int main(){
	scanf("%d",&n);fac[0]=1;
	for(int i=1;i<=K;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[K]=power(fac[K],P-2);
	for(int i=K;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=1,u,v;i<=n;i++){
		scanf("%d%d",&u,&v);
		dp[M-u][M-v]++;
		cl[M+u][M+v]++;
		m=max(m,max(u,v));
		ans-=C(u*2+v*2,u*2);
	}
	ans=(ans%P+P)%P;
	for(int i=M-m;i<=M+m;i++)for(int j=M-m;j<=M+m;j++)if(ll&w=dp[i][j]){
		if(w>=lim_mod)w%=lim_mod;
		if(cl[i][j]){
			while(cl[i][j]--){
				ans+=w;
				if(ans>=lim_mod)ans%=lim_mod;
			}
		}
		dp[i][j+1]+=w;dp[i+1][j]+=w;
	}
	ans=ans%P*(P/2+1)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 159872
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n,ans=0,a,b;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",&a,&b);
		ans=ans+max(a,b)-min(a,b)+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	vll a(5);
	rep(i, 5) cin >> a[i];
	ll ans = 0;
	ll tmp = 0;
	rep(i, 5) {
		if (a[i] % 10 == 0) {
			tmp = max((ll)0, tmp);
			ans += a[i];
		}
		else {
			tmp = max(tmp, 10 - a[i] % 10);
			ans += (a[i] / 10) * 10 + 10;
		}
	}
	cout << ans - tmp << endl;

}

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

using namespace std;

template <typename A, typename B>string to_string(pair<A, B> p);

template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {return '"' + s + '"';}

string to_string(const char* s) {return to_string((string) s);}

string to_string(bool b) {return (b ? "true" : "false");}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}

template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main(){	
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int s_len = s.length();
	int t_len = t.length();
	int chr = 0;
	int ans = t_len;
	int j, k;
	for (int i = 0; i < s_len - t_len + 1; i++){
//		cout << s[i] << "\n";
		for (j = i, k = 0; j < i + t_len; j++, k++){
			if (s[j] == t[k]){
				++chr;
			}
			if (k == t_len - 1){
				ans = min(t_len - chr, ans);
				chr = 0;
			}
		}
	}	
	cout << ans;
    return 0;
}












Measured memory_bytes: 3596
N = int(input())

A = [0]
for i in input().split():
  A.append(int(i))
A.append(0)

S = 0
for i in range(N+1):
  S += abs(A[i+1] - A[i])

for i in range(N):
  a1 = A[i]
  a2 = A[i+1]
  a3 = A[i+2]
  if (a1 <= a2 <= a3) or (a3 <= a2 <= a1):
    print(S)
  elif (a1 <= a3 <= a2) or (a2 <= a3 <= a1):
    print(S - 2 * abs(a3 - a2))
  else:
    print(S - 2 * abs(a1 - a2))

Measured memory_bytes: 64236
n = int(input())
dp = [0] * (2 * n + 1)
dp[n] = 1
for p in map(float, input().split()):
    ndp = [0] * (2 * n + 1)
    for i in range(1, 2 * n):
        ndp[i-1] += dp[i] * (1 - p)
        ndp[i+1] += dp[i] * p
    dp = ndp
print(sum(dp[n+1:]))

Measured memory_bytes: 76364
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m,ans;
struct store{
	ll a;
	ll b;
}sz[100005];
inline bool cmp(store s1,store s2)
{
	return s1.a<s2.a;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(register int i=1;i<=n;i++)
	{
		cin>>sz[i].a>>sz[i].b;
	}
	sort(sz+1,sz+n+1,cmp);
	ans=0;
	int cnt=1;
	while(1)
	{
		if(m>sz[cnt].b)
		{
			m-=sz[cnt].b;
			ans+=(sz[cnt].a*sz[cnt].b);
			cnt++;
			continue;		
		}	
		else if(m<=sz[cnt].b)
		{
			ans+=m*sz[cnt].a;
			break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int a,b;
		scanf("%d%d",&a,&b);
		(a<2*b)? printf("0") : printf("%d",a-2*b);
		return 0;
}  


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;



int main(){
    LL N,K;cin >> N >> K;
    vector<LL> vec;
    for(int a = 0;a < N;a++){
        LL b;cin >> b;
        vec.push_back(b);
    }
    bitset<50> ans(0);
    for(int index = 49;index >= 0;index--){
        int zero = 0;
        int one = 0;
        for(int a = 0;a < N;a++){
            bitset<50> W(vec.at(a));
            if(W[index] == 0)zero++;
            else one++;
        }
        if(zero > one){
            ans[index] = 1;
            if(K < ans.to_ulong())ans[index] = 0;
        }
    }
    LL Q = ans.to_ulong();
    LL Ans = 0;
    for(int a= 0;a < N;a++){
        Ans += (Q^vec.at(a));
    }
    cout<<Ans<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    int n; cin >> n;
    int cnt = 0;
    for(int i=1; i<=n; i++){
        if(to_string(i).size()%2 == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<char>> a(N,vector<char>(M));
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>a[i][j];
    }
  }


    sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      
    cout<<a[i][j];
    }
  }
}
  

      


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	char a[10101],b[10100];
	scanf("%[^\n]",a);
	int k=0;
	int l=strlen(a);
	for(int i=0;i<l;i++)
	{
		if(i==0)
		b[k++]=a[0]-32;
		else if(a[i]==' '&&a[i+1]!=' ')
		b[k++]=a[i+1]-32;
	}
	printf("%s\n",b);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//79502884197169399375105820974944
  int r;
   cin>>r;
   long double pi=3.141592653;
long  double ans = 2*r*pi;
cout<<ans<<setprecision(6);

  return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
    char search[21], word[21];
    int count=0;
    int i;
    
    scanf("%s", search);
    while(1){
        scanf(" %s", word);
        if(strcmp(word, "END_OF_TEXT")==0)break;
        for(i=0;word[i]!='\0';i++){
            word[i]=tolower(word[i]);
        }
        if(strcmp(word, search)==0){
            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 552
def solve():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))
    ans = 0
    min_diff = 10 ** 9
    for idx, hi in enumerate(h):
        diff = abs(t - hi * 0.006 - a)
        if diff < min_diff:
            min_diff = diff
            ans = idx + 1
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int n,k,aa,a[6]={500,100,50,10,5,1};
	while(scanf("%d",&n),n!=0){
		n=1000-n;
		k=0,aa=0;
		while(1){
			if(n==0)break;
			while(n<a[aa])++aa;
			n-=a[aa];
			++k;
		}
		printf("%d\n",k);
	}
	return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<cmath>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;

int main()
{
long long a,b,c,d,x,y,maxx=0; cin>>a>>b>>c>>d;
cout<<max(max(a*c,a*d),max(b*c,b*d));
return 0;
}


Measured memory_bytes: 3616
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

prevIdx = -99
ret = 0
for a in A:
    a -= 1
    ret += B[a]
    if a == prevIdx + 1:
        ret += C[a - 1]
    prevIdx = a
print(ret)

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    r = 1
    c = 0
    for b in a:
        if b <= c * 2:
            r *= c+1
            r %= mod
        else:
            c += 1
    for b in range(2,c+1):
        r *= b
        r %= mod

    return r


print(main())



Measured memory_bytes: 16528
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int A =scan.nextInt();
		int B =scan.nextInt();
		int counts=0;
        char[][] a = new char[A][A];
        char[][] b = new char[B][B];
        for(int i=0;i<A;i++){
        	char[] c=scan.next().toCharArray();
        	for(int f=0;f<A;f++){
        	a[i][f] =c[f];
        	}
        }
        for(int i=0;i<B;i++){
        char[] c=scan.next().toCharArray();
        	for(int f=0;f<B;f++){
        	b[i][f] =c[f];
        	}
        }
        for(int j=0;j<=A-B;j++){
        for(int g=0;g<=A-B;g++){
        	counts=0;
        for(int i=0;i<B;i++){
        	int count =0;
        	for(int f=0;f<B;f++){
        		if(a[i+j][f+g]==b[i][f]){
        			count++;
        		}else{
        			break;
        		}
        	}
        	if(count==B){
        		counts++;
        	}else{
        		break;
        	}
        	if(counts==B){
        		System.out.println("Yes");
        		System.exit(0);
        	}
        }
        }
	}
        System.out.println("No");
	}
	public static char[] cha(String s){
		char a[] = new char[s.length()];
		for(int i=0;i<s.length();i++){
			a[i]=s.charAt(i);
		}
		return a;
	}}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY  (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
	queue<int> q;
	q.push(s);
	V[s] = true;
	while(!q.empty()){
		int u = q.front(); q.pop();
		out.push_back(u);
		for(int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			indeg[v]--;
			if(indeg[v] == 0 && !V[v]){
				V[v] = true;
				q.push(v);
			}
		}
	}
}

void tsort(){
	for(int i = 0; i < N; i++){
		indeg[i] = 0;
	}

	for(int u = 0; u < N; u++){
		for(int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			indeg[v]++;
		}
	}

	for(int u = 0; u < N; u++)
		if(indeg[u] == 0 && !V[u]) bfs(u);

	for(list<int>::iterator it = out.begin(); it != out.end(); it++){
		cout << *it << endl;
	}
}

int main(void){
	int s, t, M;

	cin >> N >> M;

	for(int i = 0; i < N; i++) V[i] = false;

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

	tsort();

	return 0;
}

Measured memory_bytes: 6168
#include<iostream>

using namespace std;

#define MAX 25
#define NIL -1

struct Node 
{
    int parent, left, right;
};

Node T[MAX];

void preorder(int u)
{
    if(u == NIL)
        return;

    cout << " " << u ;
    preorder(T[u].left);
    preorder(T[u].right);
}

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

    inorder(T[u].left);
    cout << " " << u ;
    inorder(T[u].right);
}

void postorder(int u)
{
    if(u == NIL)
        return;

    postorder(T[u].left);
    postorder(T[u].right);
    cout << " " << u ;
}

int depth(int i)
{
    int count = 0;
    int c = i;

    while(T[c].parent != NIL)
    {
        c = T[c].parent;
        count++;
    }

    return count;
}

int height(int i)
{
    if (T[i].left == NIL && T[i].right == NIL)
    {
        return 0;
    }

    int dl, dr;
    dl = dr = 0;

    if (T[i].left != NIL)
    {
        dl = height(T[i].left) + 1;
    }

   if (T[i].right != NIL)
    {
        dr = height(T[i].right) + 1;
    }

    return max(dl,dr);
}

int sibling(int i)
{
    if (T[i].parent == NIL)
    {
        return NIL;
    }
    else
    {
        int p = T[i].parent;

        if(T[p].left != NIL && T[p].right != NIL)
        {
            if (T[p].left == i)
            {
                return T[p].right;
            }
            else
            {
                return T[p].left;
            }
        }
    }

    return NIL;
}

int degree(int i)
{
    int count = 0;

    if (T[i].left != NIL)
    {
        count++;
    }

    if (T[i].right != NIL)
    {
        count++;
    }

    return count;
}

string nodeType(int i)
{
    if (T[i].parent == NIL)
    {
        return "root";
    }
    else if (T[i].left == NIL && T[i].right == NIL)
    {
        return "leaf";
    }
    else
    {
        return "internal node";
    }
}

void printNode(int i)
{
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "sibling = " << sibling(i) << ", ";
    cout << "degree = " << degree(i) << ", ";
    cout << "depth = " << depth(i) << ", ";
    cout << "height = " << height(i) << ", ";
    cout << nodeType(i);

    cout << endl;
}

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

    for (int i = 0; i < N; i++)
    {
        T[i].parent = T[i].left = T[i].right = NIL;
    }

    for (int i = 0; i < N; i++)
    {
        int id;
        cin >> id;

        cin >> T[id].left;
        cin >> T[id].right;

        if (T[id].left != NIL)
        {
            T[T[id].left].parent = id;
        }

        if (T[id].right != NIL)
        {
            T[T[id].right].parent = id;
        }
    }

/*
    for (int i = 0; i < N; i++)
    {
        printNode(i);
    }
*/
    int root = 0;

    for (int i = 0; i < N; i++)
    {
       if(T[i].parent == NIL)
       {
           root = i;
           break;
       }
    }

    cout << "Preorder" << endl;
    preorder(root);
    cout << endl;

    cout << "Inorder" << endl;
    inorder(root);
    cout << endl;

    cout << "Postorder" << endl;
    postorder(root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3104
MOD = 10**9 + 7
memo = {}

def ok(last4):
    if "AGC" in last4:
        return False
    for i in range(3):
        s = list(last4)
        s[i], s[i+1] = s[i+1], s[i]
        if "AGC" in "".join(s):
            return False
    return True

def dfs(d, last3):
    if d < 0:
        return 1
    if not (d, last3) in memo:
        res = 0
        for c in "ACGT":
            last4 = last3 + c
            if ok(last4):
                res = (res + dfs(d-1, last4[-3:])) % MOD
        memo[d, last3] = res
    return memo[d, last3]

def solve(n):
    return dfs(n-1, "###")

n = int(input())
print(solve(n))

Measured memory_bytes: 4612
#include<stdio.h>
#define M 10001
#define VM 2000001
int c[M],A[VM],B[VM];
int main(){
	int i,n,j,k;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d",&A[i]);
	}
	for(i=0;i<n;i++) c[A[i]]++;
	for(i=0,j=0;i<M;i++){
		while(c[i]){
			B[j]=i;
			j++;
			c[i]--;
		}
	}
	for(i=0;i<j;i++){
		if(i!=0) printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
} 


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

int main(){
    int sec, h, m, s;
    cin >> sec;
    h = sec / 3600;
    m = (sec%3600) / 60;
    s = (sec%3600) % 60;
    cout << h << ":" << m << ":" << s << "\n";
    return 0;
}


Measured memory_bytes: 3132
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }

    return 0;
}

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

//
int n;
vector<vector<int>>dp;
vector<vector<bool>>a;
//

int F(int idx, int mask)
{
	if (idx == n)
		return 1;
	int ans = 0;
	if (dp[idx][mask] != -1)
		return dp[idx][mask];
	for (int i = 0; i < n; i++)
	{
		if ((mask >> i) & 1 && a[idx][i])
			ans = (ans + 0ll + F(idx + 1, mask ^ (1 << i))) % MOD;
	}
	return (dp[idx][mask] = ans);
}

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

	cin >> n;
	a = vector<vector<bool>>(n, vector<bool>(n, 0));
	dp = vector<vector<int>>(n, vector<int>(1 << n, -1));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			int x; cin >> x;
			a[i][j] = x;
		}
	}
	cout << F(0, (1 << n) - 1);

	return 0;
}

Measured memory_bytes: 183484
N, M = map(int, input().split())
KA = []
for i in range(N):
    KA.append(input().split())

m = [0] * (M+1)

for ka in KA:
    for i, s in enumerate(ka):
        if i != 0:
            m[int(s)] += 1

ans = 0
for s in m:
    if s == N:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    string s;
    cin>>s;
    long long ans=0,si=s.size();
    f2(i,s.size()-1,-1){
        if(s[i]=='B'){
            ans+=si-i-1;
            si--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int digits(long long x) {
  int res = 0;
  while (x>0) {
    res++;
    x /= 10;
  }
  return res;
}

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

  long long n;
  cin >> n;
  int res = 1e9;
  for (long long a = 1; a*a <= n; ++a) {
    if (n%a == 0) {
      int tmp = (a < n/a ? digits(n/a) : digits(a));
      if (tmp < res) res = tmp;
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
 static long mergeSort(int[] arr, int i1,int j1){
 	if(i1==j1&&arr[i1]==arr[j1]){return 1;}
        if(i1>=j1){return 0;}
        int m=(i1+j1)/2;
        long x=mergeSort(arr,i1,m)+mergeSort(arr,m+1,j1);
        int[] l=new int[m-i1+1];
        int[] r=new int[j1-m];
        for(int i=i1;i<=m;i++){l[i-i1]=arr[i];}
        for(int i=m+1;i<=j1;i++){r[i-(m+1)]=arr[i];}
        int i=0,j=0,k=i1;
        while(i<m-i1+1&&j<j1-m){
            if(l[i]>=r[j]){arr[k]=r[j];x++;j++;k++;}
            else {arr[k]=l[i];i++;k++;}
        }
        while(i<m-i1+1){arr[k]=l[i];i++;k++;}
        while(j<j1-m){arr[k]=r[j];j++;k++;}
        return x;
    }
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n=s.nextInt();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){arr[i]=s.nextInt();}
       	int[] dp=new int[n+1];dp[0]=10000000;
       int res=0;
       for(int i=1;i<=n;i++){
       	dp[i]=Math.min(dp[i-1],arr[i-1]);
       	if(arr[i-1]<=dp[i]){res++;}
       }
       out.write(res+"");
        out.flush();
  }
}


Measured memory_bytes: 87432
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
template <class T>
inline void chmax(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void chmin(T& a, T b) {
  if (a > b) a = b;
}

int solve(int n, vector<int> steps) {
  const ll INF = 1LL << 60;
  vector<ll> dp(n, INF);

  dp.at(0) = 0;

  for (ll i = 1; i < n; ++i) {
    chmin(dp.at(i), dp[i - 1] + abs(steps.at(i) - steps.at(i - 1)));
    if (i >= 2) {
      chmin(dp.at(i), dp[i - 2] + abs(steps.at(i) - steps.at(i - 2)));
    }
  }
  return dp.at(n - 1);
}

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

  vector<int> steps(n);
  for (int i = 0; i < n; ++i) {
    cin >> steps.at(i);
  }
  cout << solve(n, steps) << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <string>
#define M 5070721
#define NIL (-1)
#define L 14
using namespace std;
typedef long long ll;
char H[M][L];

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;
}

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

int h1(int key){
	return key%M;
}

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

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

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


int main(void){
	int n;
	char str[L],com[9];
	for(int i=0;i<M;i++){
		H[i][0]='\0';
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %s",com,str);
		if(com[0]=='i'){
			insert(str);
		}else{
			if(find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 70360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> p[20],b;
    rep(i,m){
        int a;
        cin>>a;
        b.push_back(a);
    }
    rep(i,n){
        rep(j,m){
            int a;
            cin>>a;
            p[i].push_back(a);
        }
    }
    int ans=0,cnt=0;
    rep(i,n){
        cnt=0;
        rep(j,m){
            cnt+=p[i][j]*b[j];
        }
        cnt+=c;
        if(cnt>0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

struct BipartiteGraph {
	struct Edge {
		const int from;
		const int to;
		Edge(const int from, const int to) :
			from(from),
			to(to)
			{}
	};
	const int V;
	vector<vector<Edge>> G;
	vector<int> color;
	BipartiteGraph(const int V) :
		V(V),
		G(vector<vector<Edge>>(V, vector<Edge>())),
		color(vector<int>(V, -1))
		{}
	void addEdge(const int from, const int to) {
		G[from].emplace_back(from, to);
		G[to].emplace_back(to, from);
	}
	bool dfs(const int from, const int col) {
		color[from] = col;
		bool ret = true;
		for(Edge e : G[from]) {
			if(color[e.to] == -1) {
				ret &= dfs(e.to, col ^ 1);
			}
			if(color[e.to] == col) {
				return false;
			}
		}
		return ret;
	}
	int bipart() {
		if(not dfs(0, 0)) throw "NOT Bipartite Graph";
		int ret = 0;
		for(int i : color) ret += i;
		return ret;
	}
};

int main() {
	int n; cin >> n;
	BipartiteGraph bg(n);
	rep(i,n-1) {
		int a, b; cin >> a >> b;
		--a, --b;
		bg.addEdge(a, b);
	}
	int l = bg.bipart();
	int r = n - l;
	pair<int, int> p[2] = {{l, 1}, {r, 0}};
	sort(p, p + 2);
	reverse(p, p + 2);
	int cnt[3] = {};
	cnt[0] = (n + 2) / 3;
	cnt[1] = n / 3 + (n % 3 == 2 ? 1 : 0);
	cnt[2] = n - cnt[0] - cnt[1];
	int one = 1, two = 2, three = 3;
	int ans[n];
	// cerr << l << " " << r << '\n';
	// cerr << cnt[0] << " " << cnt[1] << '\n';
	if(p[0].first >= cnt[0] and p[1].first >= cnt[1]) {
		for(int i = 0; i < n; ++i) {
			if(bg.color[i] == p[0].second) {
				if(cnt[0] > 0) {
					ans[i] = one;
					one += 3;
					cnt[0]--;
				} else {
					ans[i] = three;
					three += 3;
				}
			} else {
				if(cnt[1] > 0) {
					ans[i] = two;
					two += 3;
					cnt[1]--;
				} else {
					ans[i] = three;
					three += 3;
				}
			}
		}
	} else if(p[1].first <= cnt[2]) {
		for(int i = 0; i < n; ++i) {
			if(bg.color[i] == p[1].second) {
				ans[i] = three;
				three += 3;
			} else {
				if(cnt[0] > 0) {
					ans[i] = one;
					one += 3;
					cnt[0]--;
				} else if(cnt[1] > 0) {
					ans[i] = two;
					two += 3;
					cnt[1]--;
				} else {
					ans[i] = three;
					three += 3;
				}
			}
		}
	} else {
		cout << -1 << '\n';
		return 0;
	}
	for(int i = 0; i < n; ++i) {
		cout << ans[i] << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 15848
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for A - Traveling Budget
	var A, B, C, D int
	fmt.Scanf("%d\n%d\n%d\n%d", &A, &B, &C, &D)

	fmt.Println(math.Min(float64(A), float64(B)) + math.Min(float64(C), float64(D)))
}


Measured memory_bytes: 1836
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#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 pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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 GetDir(int x1,int y1,int x2,int y2){
	if(x1<x2) return 1;//right
	else if(x1>x2) return 3;//left
	else if(y1>y2) return 4;//down
	else if(y1<y2) return 2;//up
	return 0;
}
vi GetMageData(vi x,vi y){
	vi rst;
	int olddir = GetDir(x[0],y[0],x[1],y[1]);
	FOR(i,1,x.size()-1){
		int newdir = GetDir(x[i],y[i],x[i+1],y[i+1]);
		int mage;
		if(olddir==1){
			if(newdir==2) mage=1;//hantai
			else mage = 0;//clock
		}else if(olddir==2){
			if(newdir==3) mage=1;
			else mage = 0;
		}else if(olddir==3){
			if(newdir==4) mage=1;
			else mage = 0;
		}else{
			if(newdir==1) mage=1;
			else mage=0;
		}
		rst.pb(mage);
		olddir = newdir;
	}
	return rst;
}

vi GetDisData(vi x,vi y){
	vi rst;
	int sx = 0,sy = 0;
	FOR(i,1,x.size()){
		x[i] -= x[0];
		y[i] -= y[0];
	}
	x[0] = 0; y[0] = 0;
	FOR(i,1,x.size()){
		rst.pb((x[i]-sx)*(x[i]-sx)+(y[i]-sy)*(y[i]-sy));
		sx = x[i]; sy  =y[i];
	}
	return rst;
}
int main(){
	int n;
	vi len01,mag01,len02,mag02;
	int num0;
	while(1){
		cin >> n;
		if(n==0) break;
		//0
		vi tx,ty,tx2,ty2;
		cin >> num0;
		REP(i,num0){
			int xx,yy;
			cin >> xx >> yy;
			tx.pb(xx);
			ty.pb(yy);
		}
		len01.clear();
		len02.clear();
		mag02.clear();
		mag02.clear();

		tx2 = tx,ty2 = ty;
		len01 = GetDisData(tx,ty);
		mag01 = GetMageData(tx,ty);
		reverse(All(tx2));
		reverse(All(ty2));
		len02 = GetDisData(tx2,ty2);
		mag02 = GetMageData(tx2,ty2);

		/*REP(kk,len01.size()){
			cout << len01[kk] << " ";
		}
		cout << endl;
		REP(kk,mag01.size()){
			cout << mag01[kk] << " ";
		}
		cout << endl;
		REP(kk,len02.size()){
			cout << len02[kk] << " ";
		}
		cout << endl;
		REP(kk,mag02.size()){
			cout << mag02[kk] << " ";
		}
		cout <<"hogehogehoge"<< endl;*/

		REP(i,n){
			int k;
			vi l,m;
			vi dx,dy;
			cin >> k;
			REP(j,k){
				int xxx,yyy;
				cin >> xxx >> yyy;
				dx.pb(xxx); dy.pb(yyy);
			}
			l = GetDisData(dx,dy);
			m = GetMageData(dx,dy);

			/*REP(kk,l.size()){
				cout << l[kk] << " ";
			}
			cout << endl;
			REP(kk,m.size()){
				cout << m[kk] << " ";
			}
			cout << endl;*/
			bool flg = false;
			if(l==len01&&m==mag01) flg = true;
			if(l==len02&&m==mag02) flg = true;
			if(flg) cout << i+1 << endl;
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 1224
#include<cstdio>
#include<map>
using namespace std;
const int MAXN=200005;

struct DSU
{
	int fa[MAXN];
	int Root(int x)
	{return fa[x]==0?x:fa[x]=Root(fa[x]);}
	void Union(int x,int y)
	{
		int r1=Root(x),r2=Root(y);
		if(r1==r2)
			return;
		fa[r1]=r2;
	}
};

DSU s1,s2;
map<int,int> cnt[MAXN];

int main()
{
	int N,K,L;
	scanf("%d%d%d",&N,&K,&L);
	for(int i=1,x,y;i<=K;i++)
	{
		scanf("%d%d",&x,&y);
		s1.Union(x,y);
	}
	for(int i=1,x,y;i<=L;i++)
	{
		scanf("%d%d",&x,&y);
		s2.Union(x,y);
	}
	for(int i=1;i<=N;i++)
		cnt[s1.Root(i)][s2.Root(i)]++;
	for(int i=1;i<=N;i++)
		printf("%d ",cnt[s1.Root(i)][s2.Root(i)]);
	puts("");
	
	return 0;
}


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

using namespace std;

int main()
{

    int n, mini = 100;
    cin >> n;

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

    int ans = h[0];

    for (int i = 1; i < n; i++)
    {
        if (h[i] > h[i - 1])
        {
            ans += h[i] - h[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<string>
#include<iostream>
#define R(i, n) for(int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d",  &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define P(a) printf("%d\n", a)
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> IR;

int main(){
	ll n;
	SL(n);
	string s;
	while(n){
		n--;
		s += (char)('a' + (n % 26));
		n /= 26;
	}
	reverse(s.begin(), s.end());
	printf("%s", s.c_str());
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 





int32_t main()
{
	IOS
	int n;cin>>n;
	cout<<3*n*n<<endl;
	
	
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
price = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            price= (a * 500) +(b * 100) + (c * 50)
            if price == X :
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

print("error" if A+B >= 10 else A+B)


Measured memory_bytes: 5144
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 2e5+5
int n;
vector<pair<int,int>> v;
int catche[20000][1008];
int dp(int h, int idx){
    if(h<=0){
        return 0;
    }
    if(idx>=n){
        return inf;
    }
    int &ans=catche[h][idx];
    if(ans!=-1) return ans;

    ans=min(dp(h-v[idx].first, idx)+v[idx].second, dp(h,idx+1));
    return ans;
}



int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int h;
    
       cin >> h >> n;
       mem(catche,-1);
       int i,j;
       for(i=1; i<=n; i++){
           int x,y;
           cin >> x >> y;
           v.pb(make_pair(x,y));
       }

       cout << dp(h,0) << '\n';
        
        

}

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

using namespace std;

double a,b;

bool input(){
  if(!(cin>>a>>b))return false;
  return true;
}

double solve(){
  double t = 3.305785;
  return a*b/t;
}

int main(){

  while(input()){
    //cout<<solve()<<endl;
    printf("%.9lf\n",solve());
  }
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    string S, ans = "Yes";
    cin >> S;
    rep(i, S.size()) {
        if ((i % 2 == 0 && S[i] == 'L') || (i % 2 == 1 && S[i] == 'R')) ans = "No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256