akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

char num[200001];

inline int comp(char me , char you){
	if(me == you)
		return 0;
	else
		return me > you ? 1 : -1;
}

int main(){
	scanf("%s" , num);
	int l = strlen(num) , ans = 0;
	for(int i = 0 ; i < l ; i++)
		ans += comp(i & 1 ? 'p' : 'g' , num[i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())

A = []
B = []
graph = [[False for i in range(N)] for j in range(N)]
visited = [False for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    A.append(a-1)
    B.append(b-1)
    graph[A[i]][B[i]] = True
    graph[B[i]][A[i]] = True

ans = 0

def dfs(v):
    visited[v] = True
    for v2 in range(N):
        if graph[v][v2]==False:
            continue
        if visited[v2]==True:
            continue
        dfs(v2)

for i in range(M):
    graph[A[i]][B[i]] = False
    graph[B[i]][A[i]] = False
    
    for j in range(N):
        visited[j] = False
               
    dfs(0)
    
    bridges = False
    
    for j in range(N):
        if visited[j]==False:
            bridges = True
            break
        
    if bridges:
        ans += 1
        
    graph[A[i]][B[i]] = True
    graph[B[i]][A[i]] = True

print(ans)



Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){

    int N,M,K,a,i,j,ans=0;
    cin >> N >> M;

    int B[M]={0};

    for(i=0 ; i<N ; i++){
        cin >> K;
        for(j=0 ; j<K ; j++){
            cin >> a;
            B[a-1] += 1;
        }
    }

    for(i=0 ; i<M ; i++){
        if(B[i] == N){
            ans++;
        }
    }

    cout << ans << endl;

}


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

int main() {
  int e, m;

  while(1) {
    cin >> e;
    if(e == 0) break;

    m = e;
    for(int z = 0; z * z * z <= e; ++z)	{
      for(int y = 0; y * y <= e - z * z * z; ++y) {
        int x =	e - y *	y - z *	z * z;
        m = min(m, x + y + z);
      }
    }

    cout << m << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll h,w;
ll d[]={0,1,0,-1,0};
char s[99][99];
int main(){
	scanf("%lld%lld\n",&h,&w);
	rep(i,0,h)scanf("%s",s[i+1]+1);
	ll ans=1;
	rep(i,1,h+1)rep(j,1,w+1)if(s[i][j]=='#'){
		ll flag=0;
		rep(k,0,4)flag|=s[i+d[k]][j+d[k+1]]=='#';
		ans&=flag;
	}
	puts(ans?"Yes":"No");
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int q = Integer.parseInt(sa[1]);

		sa = br.readLine().split(" ");
		int[] pre = new int[n + 1];
		int[] last = new int[n + 1];
		for (int i = 0; i < n; i++) {
			int c = Integer.parseInt(sa[i]);
			pre[i + 1] = last[c];
			last[c] = i + 1;
		}

		PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> o1.r - o2.r);
		Obj[] arr = new Obj[q];
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			Obj o = new Obj();
			o.i = i;
			o.l = Integer.parseInt(sa[0]);
			o.r = Integer.parseInt(sa[1]);
			que.add(o);
			arr[i] = o;
		}
		br.close();

		BIT bit = new BIT(n);
		int j = 1;
		while (!que.isEmpty()) {
			Obj o = que.poll();
			while (j <= o.r) {
				bit.add(j, 1);
				if (pre[j] > 0) {
					bit.add(pre[j], -1);
				}
				j++;
			}
			o.ans = bit.sum(o.r) - bit.sum(o.l - 1);
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			pw.println(arr[i].ans);
		}
		pw.flush();
	}

	static class Obj {
		int i, l, r, ans;
	}

	static class BIT {
		int n;
		int[] arr;

		public BIT(int n) {
			this.n = n;
			arr = new int[n + 1];
		}

		void add(int idx, int val) {
			for (int i = idx; i <= n; i += i & -i) {
				arr[i] += val;
			}
		}

		int sum(int idx) {
			int sum = 0;
			for (int i = idx; i > 0; i -= i & -i) {
				sum += arr[i];
			}
			return sum;
		}
	}
}


Measured memory_bytes: 104168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = (b - a) / 2;
  if ((b - a) % 2) {
	  ans += min(a - 1, n - b) + 1;
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19;

char T[maxN];

void solve()
{
	int p, q ;
	scanf ("%d%d", &p, &q);
	printf("%s\n", p == q ? "Yes" : "No");	
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}





Measured memory_bytes: 3740
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */

int main() {
	int a, t;
	string s;
	pair<pair<string, int>, int> p[100];
	cin >> a;
	REP(i, a) {
		cin >> s >> t;
		p[i] = make_pair(make_pair(s, -t), i);
	}
	sort(p, p + a);
	REP(i, a) cout << p[i].second + 1 << endl;
}

Measured memory_bytes: 256
import itertools
import numpy as np
def main():

    n,m,x = tuple([int(t)for t in input().split()])

    a = [np.array([int(t)for t in input().split()])for _ in [0]*n]
    candidate = []
    for i in range(n):
        for data in itertools.combinations(a,i+1):
            data = sum(data)
            if np.all(data[1:]>=x):
                candidate.append(data[0])
    if len(candidate)==0:
        print(-1)
    else:
        print(min(candidate))


if __name__ == "__main__":
    main()

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

int main()
{
    long long a, b, c, ans = 0;
    std::cin >> a >> b >> c;
    if (a + b + 1 >= c) { ans = b + c; }
    else
    {
        ans = b + (a + b + 1);
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

bool prime(int k)
{
    for(int i = 2; i * i <= k; i++){
        if(k % i == 0){
            return false;
        }
    }
    return true;
}

int main() {
    //cout.precision(10);
    int dp[100010];
    dp[1] = 0;
    dp[0] = 0;
    for(int i = 2; i <= 100000; i++){
        dp[i] = dp[i - 1];
        if((i % 2 == 1) && prime(i) && prime((i + 1) / 2)){
            dp[i]++;
        }
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++){
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
 int H, W;
 for(;;)
 {
  cin >> H >> W;
  if(H == 0 && W == 0) break;
  for(int i=0; i<H; ++i)
  {
    for(int j=0; j<W; ++j)
    {
      if(((i+j) & 1) == 0) cout << "#";
      else cout << ".";      
    }
    cout << endl;
  }
  cout << endl;
 }
 return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
int main(void)
{
	int Case[10000],i,x;
	for(i=1;i<=10000;i++)
	{
		scanf("%d",&x);
		if(x==0)
		{
			break;
		}
		printf("Case %d: %d\n",i,x);
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll base = 0;
  if (k <= a + b) {
    base = min(k, a);
  } else {
    base = a;
    k -= (a + b);
    auto bad = min(k, c);
    base -= bad;
  }
  cout << base << '\n';
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your code here Tanmay:)
	int a,b;
	cin>>a>>b;
	if(a==b)
		cout<<"Yes";
	else
		cout<<"No";
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll C[202020];
vector<pll> abv[202020];
ll mk[202020];
ll anss[202020];
ll i, j, k;
ll ndfs(ll a,ll p,ll d){
    ll i, j, k;
    ll dd = 1, ddd = 1;
    fornum(i,0,abv[a].size()){
        ll b = abv[a][i].first;
        if(b==p){
            abv[a][i].second = d;
            dd += d;
        }else{
            dd += abv[a][i].second;
        }
    }
    
    fornum(i,0,abv[a].size()){
        ll b = abv[a][i].first;
        if(b==p)
            continue;
        abv[a][i].second = ndfs(b, a, dd - abv[a][i].second);
        ddd += abv[a][i].second;
    }
    //printf("%lld,%lld,%lld\n", a, d, ddd);
    return ddd;
}

void dfs(ll a,ll p){
    ll i, c = mk[C[a]];
    fornum(i,0,abv[a].size()){
        ll b = abv[a][i].first;
        if(b==p)
            continue;
        c -= abv[a][i].second;
        anss[C[a]] += c * abv[a][i].second;
    }
    anss[C[a]] += c;
    fornum(i,0,abv[a].size()){
        ll b = abv[a][i].first;
        if(b==p)
            continue;
        mk[C[a]] = abv[a][i].second;
        dfs(b, a);
    }
    mk[C[a]] = c - 1;
    //printf("%lld,%lld,%lld\n", a, C[a], mk[C[a]]);
}

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &C[i+1]);
    }
    fornum(i,1,N){
        ll a,b;
        scanf("%lld%lld", &a,&b);
        abv[a].push_back({b, 0});
        abv[b].push_back({a, 0});
    }
    ndfs(1, 0, 0);
    ndfs(1, 0, 0);
    fornum(i,0,N){
        mk[i + 1] = N;
    }

    dfs(1, 0);
    fornum(i,0,N){
        printf("%lld\n", anss[i + 1]);
    }
    return 0;
}

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) ll(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    LLvector vec (5,0);
    LL N;
    cin >> N;
    for(LL i = 0;i < N;i++){
        string dummy;
        cin >> dummy;
        if(dummy.at(0) == 'M'){
            vec.at(0)++;
        }
        if(dummy.at(0) == 'A'){
            vec.at(1)++;
        }
        if(dummy.at(0) == 'R'){
            vec.at(2)++;
        }
        if(dummy.at(0) == 'C'){
            vec.at(3)++;
        }
        if(dummy.at(0) == 'H'){
            vec.at(4)++;
        }
    }
    cout << vec[0] * vec[1] * vec[2] + vec[0] * vec[1] * vec[3] + vec[0] * vec[1] * vec[4] + vec[0] * vec[2] * vec[3] + vec[0] * vec[2] * vec[4] + vec[0] * vec[3] * vec[4] + vec[1] * vec[2] * vec[3] + vec[1] * vec[2] * vec[4] + vec[1] * vec[3] * vec[4] + vec[2] * vec[3] * vec[4] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){ int r, D, x;
    int arr[11];
    cin >> r >> D >> arr[0];
    for (int i = 0; i < 10; i++) {
        if (arr[i + 1] != 11) {
            arr[i + 1] = (r * arr[i]) - D;
            cout << arr[i + 1] << "\n";

        }
    }
   
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
bool check(string s){
	ll i=0;
	ll j=s.size()-1;
	while(i<j){
		if(s[i]!=s[j]) return 0;
		i++;
		j--;
	}
	return 1;
}
int main()
{
    boost;
    ll n,i,j,x,y;
	string s,t;
	cin>>s;
	n=s.size();
	if(check(s)==0){
		cout<<"No\n";
		return 0;
	}
	t=s.substr(0,((n-1)/2));
	//cout<<t<<"\n";
	if(check(t)==0){
		cout<<"No\n";
		return 0;
	}
	//cout<<t<<"\n";
	t=s.substr(((n+3)/2)-1,n-1);
	if(check(t)==0){
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a,b,c;
    cin >> a >> b >> c;
    if(c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)){
      print("Yes");
    } else {
      print("No");
    }
    

}


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    int sum = 0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int l=1;l<=k;l++)
            {
                sum = sum + __gcd(__gcd(i,j),l);

            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 2e9 + 3;
const int N = 2e5 + 3;
const int MOD = 1e9 + 9;
const double EPS = 1e-9;
 
const double PI = acos(-1);
 
void solve() {
    int x;
    cin >> x;
    cout << (1 - x);
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 3576
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	String hoge_src = sc.next();
    String egoh = sc.next();
    
    StringBuffer buff = new StringBuffer(hoge_src);
    String hoge_dst = buff.reverse().toString();
	
    if (egoh.equals(hoge_dst)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    string S, T;
    cin >> S >> T;
    VVL rec(26);
    rep(i, 0, S.size()) rec[S[i]-'a'].push_back(i);
    ll pre = -1;
    ll ans = 0;
    rep(i, 0, T.size()){
        if(rec[T[i]-'a'].empty()){
            cout << -1 << endl;
            return 0;
        }
        auto itr = upper_bound(ALL(rec[T[i]-'a']), pre);
        if(itr == rec[T[i]-'a'].end()){
            pre = rec[T[i]-'a'][0];
            ans += S.size();
        }else{
            pre = *itr;
        }
    }
    ans += pre + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1724
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<String,Integer> map = new HashMap<String,Integer>();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0)+1);
        }
        int M = sc.nextInt();
        for (int i = 0; i < M; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0)-1);
        }
        for(int val:map.values()){
            ans = Math.max(ans,val);
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 22996
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var d = long.Parse(line[1]);
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = long.Parse(line[0]);
            var y = long.Parse(line[1]);
            if (x * x + y * y <= d * d) count++;
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 45976
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main(){
  int ax,ay,bx,by,cx,cy,dx,dy;
  cin >> ax >> ay >> bx >> by;
  int vx,vy;
  vx = bx-ax; vy = by-ay;
  vy *= -1;
  swap(vx,vy);
  cx = bx+vx; cy = by+vy;
  vy *= -1;
  swap(vx,vy);
  dx = cx+vx; dy = cy+vy;
  cout << cx << " "<< cy << " " << dx << " " << dy << endl;
}



Measured memory_bytes: 256
W, H, N = map(int, input().split())
z = [list(map(int, input().split())) for _ in range(N)]
one, two, three, four = [0], [W], [0], [H]
for i in range(N):
	if z[i][2] == 1:
		one.append(z[i][0])
	elif z[i][2] == 2:
		two.append(z[i][0])
	elif z[i][2] == 3:
		three.append(z[i][1])
	else:
		four.append(z[i][1])
w = W - max(one) - (W - min(two))
h = H - max(three) - (H - min(four))
if w > 0 and h > 0:
	print(w * h)
else:
	print(0)


Measured memory_bytes: 3064
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var abcxy = Console.ReadLine().SplittedStringToInt32List();
        var a = abcxy[0];
        var b = abcxy[1];
        var c = abcxy[2]*2;
        var x = abcxy[3];
        var y = abcxy[4];
        var num1 = 0;
        var num2 = 0;
        if (x > y)
        {
            num1 = x * c;
            num2 = (x - y) * a + y * c;
        }
        else
        {
            num1 = y * c;
            num2 = (y - x) * b + x * c;
        }
        Console.WriteLine(Math.Min(a*x+b*y,Math.Min(num1,num2)));

        Console.ReadLine();
    }

    public static long f(long n,long b)
    {
        if (n < b)
        {
            return n;
        }
        else
        {
            return f((long)Math.Floor((double)n/b),b) + n % b;
        }
    }

    public static string N(long n,long b)
    {
        var sb = new StringBuilder();
        while (true)
        {
            sb.Append((n % b).ToString());
            n /= b;
            if (n < b)
            {
                sb.Append(n.ToString());
                break;
            }
        }
        return new string( sb.ToString().Reverse().ToArray() );
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    public const int Mod1e9 = 1000000007;
    

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll gcd(ll a, ll b ) {
    if ( a%b == 0 ) return b;
    return gcd(b, a%b);
}

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> xv(n);
    rep(i, n) cin >> xv[i];
    ll ans;
    rep(i, n) {
        if ( i == 0 ) ans = abs(x-xv[i]);
        else          ans = gcd(ans, abs(x-xv[i]));
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	
	cout << *max_element(a.begin(), a.end()) * 9 + a[0] + a[1] + a[2]; 
	
	return 0;
}




Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array


void solve() {
    int n, S;
    cin >> n >> S;
    vector<int> w(n), v(n);
    for(int i = 0; i < n; ++i) cin >> w[i] >> v[i];
    vector<vector<int>> dp(n,vector<int>(S+1,0));
    for(int i = 0;i < n; ++i){
        for(int j = 0;j <= S; ++j){
            if(i > 0) {
                if (w[i] > j) dp[i][j] = dp[i - 1][j];
                else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            }else{
                if(w[i] <= j) dp[i][j] = v[i];
            }
        }
    }
    //debug(dp);
    cout << dp[n-1][S] << "\n";
    //cout << *max_element(dp[n-1].begin(),dp[n-1].end()) << "\n";
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while (TC--)
        solve();

    return 0;
}



Measured memory_bytes: 82316
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ld EPS=10e-8;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll chek[100007];

int main(){
    ll N,A[100007];
    cin >> N;
    rep(i,N){
        cin >> A[i+1];
    }
    ll T=1,C=0;
    while(1){
        if(T==2){
            cout << C << endl;
            return 0;
        }
        if(chek[T]==1){
            cout << -1 << endl;
            return 0;
        }
        chek[T]=1;
        T=A[T];
        C++;
    }
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int a, b, c;
  	scanf("%d%d%d", &a, &b, &c);
  	if (a > c){
    	printf("NO");
    } else if (a + b < c){
    	printf("NO");
    } else {
    	printf("YES");
    }
}

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

int main ()
{
    int a,b,ans,p;
    cin>>a>>b;
    if(a>=10)
    {
        ans=b;
        cout<<ans<<endl;
    }

    else
    {
        p=100*(10-a);
        ans = p+b;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}
int main(){
    ll n,x;
    ll ans=0;
    cin >> n >> x;
    vector<ll>a(n);
    vector<ll>bet(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        bet[i]=a[i]+a[i+1];
    }
    rep(i,n-1){
        ll sum=a[i]+a[i+1];
        ll sub=sum-x;
        if(sub<=0) continue;
        if(sub>=a[i+1]){
            a[i+1]=0;
            a[i]-=sub-a[i+1];
        }
        else{
            a[i+1]-=sub;
        }
        ans+=sub;
    }
    cout << ans << endl;


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint choose(ll n, ll a){
    mint x, y;
    x = 1; y = 1;
    rep(i,a){
        x *= (a - i);
        y *= (n - i);
    }
    y /= x;
    return y;
    }

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    mint ans;
    ans = mint(2).pow(n) - mint(1) - choose(n, a) - choose (n, b);
    cout << ans.x << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, L int
	fmt.Scan(&N, &L)

	var taste int
	for i := 1; i <= N; i++ {
		taste += L + i - 1
	}
	if L >= 0 {
		taste -= L
	} else if L+N-1 < 0 {
		taste -= L + N - 1
	}
	fmt.Println(taste)
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int ctoi(char c) {
    if ('0' <= c && c <= '9') return c - '0';
    return -1;
}
constexpr int Y = 2019;

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

    string s;
    cin >> s;

    array<int, Y> dp = {};
    dp[0] = 1;

    int count = 0;

    for (auto &&si : s) {
        const int d = ctoi(si);

        array<int, Y> newdp = {};
        for (int i = 0; i < Y; i++) {
            newdp[(i * 10 + d) % Y] += dp[i];
        }

        count += newdp[0];

        dp = newdp;
        dp[0]++;
    }

    const int ans = count;

    cout << ans << endl;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
long long n,a[100010],b[100010],c[100010],dp[100010][4];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][1]=(a[i]+max(dp[i-1][2],dp[i-1][3]));
        dp[i][2]=(b[i]+max(dp[i-1][1],dp[i-1][3]));
        dp[i][3]=(c[i]+max(dp[i-1][1],dp[i-1][2]));
    }
    long long ans=max(dp[n][1],max(dp[n][2],dp[n][3]));
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 9208
import java.util.Scanner;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        

        if(n%2 == 0){
            System.out.println(0.5);
        }else {
            System.out.println((double)(n/2+1)/(double)n);
        }
    }

}

Measured memory_bytes: 21972
import math

n = int(input())

count = 0

def isPrimeNumber(x):
    if x == 2:
        return True
    elif x % 2 == 0:
        return False

    for i in range(3, int(math.sqrt(x)) + 2, 1):
        if x % i == 0:
            return False
    return True

for i in range(n):
    x = int(input())
    if isPrimeNumber(x):
        count += 1

print(count)



Measured memory_bytes: 5672
n=int(input())
s=input().split(' ')
m=0

for i in range(n):
	minj=i
	for j in range(i,n):
		if int(s[j])<int(s[minj]):
			minj=j
	if i!=minj:
		a=s[minj]
		s[minj]=s[i]
		s[i]=a
		m+=1
			
print(' '.join(s))
print(m)


Measured memory_bytes: 5596
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    int s1 = 0, s2 = 0;
    for (int j = 0; j <= i; j++) {
      s1 += w[j];
    }
    for (int j = i+1; j < n; j++) {
      s2 += w[j];
    }
    ans = min(ans, abs(s1-s2));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    string s; cin>>s;
    int n = (int)s.size();
    int ans = 1;
    for(int i=1;i<n;i++){
        string u = s.substr(0, n-i);
        int t = (int)u.size();
        string u1 = u.substr(0, t/2);
        string u2 = u.substr(t/2);
        if(u1==u2) {
            ans = (int)u1.size()*2;
            cout<<ans<<endl;
            return 0;
        }
    }
}

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

int main() {
	string s1,s2,s3;
	cin>>s1;
	s2=s1.substr(0,4);
	s3=s1.substr(4,11);
	cout<<s2+" "+s3<<endl;
	return 0;

}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  bool conta0 = false;
  //cout << a.size() << endl;
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    if(a.at(i) == 0){
      conta0 = true;
    }
  }
  sort(a.begin(),a.end());
  vector<int> b(3);
  //cout << b.size() <<endl;
  if(n % 3 != 0){
    bool ok = true;
    for(int i = 0;i < n;i++){
      if(a.at(i) != 0){
        ok = false;
      }
    }
    if(ok == true){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    int num = 0;
    b.at(0)++;
    for(int i = 1;i < n;i++){
      if(a.at(i-1) != a.at(i)){
        num++;
      }
      if(num >= 3){
        break;
      }
      //cout << num << endl;
      b.at(num)++;
    }
    if(conta0 != true){
      int bx = a.at(n/3)^a.at(2*n/3);
      if(b.at(0) == n/3 && b.at(1) == n/3 && b.at(2) == n/3 && bx == a.at(0)){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      if(b.at(0) == n || (b.at(0) == n/3 && b.at(1) == 2*n/3)){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 640
//Chat I am Trash
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define debug(x) cout<<x<<endl
#define all(x) x.begin(),x.end()

using namespace std;
int main()
{
    FASTIO
    double x,y;
    cin >>x >> y;
    x/=y;
    cout<<fixed<<setprecision(8)<<x;

return 0;
}


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

int div(vector<map<int,int>> vc, int n){
	int mx = 0;
  	rep(i,(1 << n)){
    	bitset<15> bt(i);
      	vector<int> hn, ly;
      	bool fct = true;
      	
      	rep(j,n){
        	if(bt.test(j)) hn.push_back(j);
          	else ly.push_back(j);	
        }
      	
      	rep(j,hn.size()){
        	rep(k,hn.size()){
            	if(vc.at(hn.at(j)).find(hn.at(k)) != vc.at(hn.at(j)).end()){
                	if(vc.at(hn.at(j))[hn.at(k)] != (int)bt.test(hn.at(k))) fct = false; 
                }
            }
          	rep(k,ly.size()){
            	if(vc.at(hn.at(j)).find(ly.at(k)) != vc.at(hn.at(j)).end()){
                	if(vc.at(hn.at(j))[ly.at(k)] != (int)bt.test(ly.at(k))) fct = false; 
                }
            }
        }
      	if(fct) mx = max(mx,(int)hn.size());
    }
  	
  	return mx;
}

int main(){
	int n;	cin >> n;
  	vector<map<int,int>> vc(n);
  	rep(i,n){
		int tmp;	cin >> tmp;
      	rep(j,tmp){
          	int hm;	cin >> hm;
          	int wh;	cin >> wh;
        	vc.at(i)[hm-1] = wh;
        }
    }
  	
  	cout << div(vc,n) << endl;
}

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

int main(void){

    int H,W; cin>>H>>W;

    vector<string> mas(H);
    for (int i = 0; i < H; ++i) {
        cin>>mas[i];
    }

    vector<bool> row(H, false), column(W, false);

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if(mas[i][j] == '#'){
                row[i] = true;
                column[j] = true;
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        if(row[i]) {
            for (int j = 0; j < W; ++j) {
                if (column[j] == true) cout << mas[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

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

int main()
{
    int n;
    long long sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int day;
  int cost[30];
  int satisfied[370][30];
  int i,j;
  
  scanf("%d",&day);
  
  for(i=0;i<26;i++){
    scanf("%d ",&cost[i]);
  }
  
  for(i=0;i<day;i++){
    for(j=0;j<26;j++){
      cin>>satisfied[i][j];
    }
  }
  
  for(i=0;i<day;i++){
    printf("%d\n",i%26+1);
  }
  return(0);
}

Measured memory_bytes: 3868
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  ll N = input();
  ll M = input();
  vector<ll> A;
  REP(i,N){
    A.push_back(input());
  }

  ll sum = std::accumulate(A.begin(),A.end(),0);
  ll count = 0;
  for(auto iter:A){
    if(iter >= (float)sum/4/M){
      count++;
    }
  }

  if(count >= M){
    output("Yes");
  }
  else{
    output("No");
  }
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N), A(N);
  rep(i, N) { cin >> P[i]; }
  rep(i, N) { cin >> Q[i]; }
  rep(i, N) { A[i] = i + 1; }
  int p, q, num = 0;
  do {
    int cntp = 0, cntq = 0;
    rep(i, N) {
      if (A[i] == P[i]) cntp++;
      if (A[i] == Q[i]) cntq++;
    }
    if (cntp == N) {
      p = num;
    }
    if (cntq == N) {
      q = num;
    }
    num++;
  } while (next_permutation(all(A)));
  cout << abs(p - q) << endl;
  return 0;
}

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

int main() {
	int ans=0,flag=0,first=0,last=99999;
	char s[100001];
	scanf("%s", s);
/*回文の先頭と末尾が同じならその2つは無視し除外できる。
sはkeepしfirstとlastの位置で何とかする。*/
	last = strlen(s)-1;
	while (flag == 0) {
		if (s[first] != s[last] && s[first] != 'x' && s[last] != 'x')flag++;
		else if (s[first] == s[last]) { first++; last--; }
		else if (s[first] == 'x' && s[last] != 'x') { first++; ans++; }
		else if (s[first] != 'x' && s[last] == 'x') { last--; ans++; }
		
		if (first >= last) { printf("%d", ans); return 0; }
	}
	printf("-1");
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k:u32,
        n: usize,
        a: [u32; n]
    }

    let mut distance: Vec<u32> = Vec::with_capacity(n);

    distance.push(a[0] + k - a[n - 1]);

    for i in 1..n {
        distance.push(a[i] - a[i - 1]);
    }

    let res = k - distance.iter().max().unwrap();
    println!("{}", res);
}


Measured memory_bytes: 8444
import math

N = int(input())
list = []
for i in range(N):
    n = input()    
    m = n.split()
    p = [int(i) for i in m]
    list.append(p)
dis = 0
while list != []:
    for a in list:
        d = (a[0] - list[0][0]) ** 2 + (a[1] - list[0][1]) ** 2
        trued = d ** 0.5
        dis = dis + trued
    else:
        list = [] + list[1:]
else:
    dis = dis * 2 / N
    print(dis)



Measured memory_bytes: 3188
//06
#include<iostream>

using namespace std;

int main(){
  for(int a,b;cin>>a>>b,a|b;){
    int w[17][17]={{}};
    bool bad[17][17]={{}};
    int n;
    cin>>n;
    while(n--){
      int x,y;
      cin>>x>>y;
      bad[y][x]=true;
    }
    for(int y=1;y<=b;y++){
      for(int x=1;x<=a;x++){
	if(x==1&&y==1){
	  w[y][x]=1;
	}else if(!bad[y][x]){
	  w[y][x]=w[y-1][x]+w[y][x-1];
	}
      }
    }
    cout<<w[b][a]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
N,M = map(int, input().split())
line_list = []
for i in range(N):
    tmp_list = list(map(int, input().split()))
    tmp_list.pop(0)
    line_list.append(tmp_list)

my_dict = {}
for line in line_list:
    for param in line:
        if param in my_dict:
            my_dict[param] += 1
        else:
            my_dict[param] = 1
ret = 0
for param in my_dict.items():
    if param[1] == N:
        ret += 1
print(ret)

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int main(void){
    lli n;
    lli res = 0;
    cin >> n;
    string s = to_string(n);
    lli len = s.size()-1;
    rep(bit, (1<<len)){
        lli ncp = n;
        vector<bool> plus(len);
        rep(i, len){
            if(bit & (1<<i)){
                plus.at(i) = true;
            }
        }
        lli sum, c;
        sum = 0;
        c = 1;
        rep(i, (len)){
            if(plus.at(i)){
                sum += ncp%(lli)pow(10, c);
                ncp /= (lli)pow(10, c);
                c = 1;
            }else c++;
        }
        sum += ncp;
        res += sum;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384