akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  string s;
  R s;
  ll n=s.size();
  ll c[26],ans=n*(n-1)/2;
  mem(c);
  rep(i,n) c[s[i]-'a']++;
  rep(i,26) ans-=c[i]*(c[i]-1)/2;
  pr(ans+1);
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 720
#include<stdio.h>

int main(){
int A,B;
scanf("%d %d",&A,&B);
for(int a=1;a<10000;a++){
	if(a*8/100==A && a*10/100==B){
		printf("%d",a);
		return 0;
	}
}
printf("-1");
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;
typedef long long ll;
#define inf 2123456789
//#define scanf scanf_s	//vs2019
#define maxn 100005
int a[123] = { 0 };
int b[123][123] = { 0 };
int c[123] = { 0 };//存d
int main() {
	int n, k, i, d, j, t, ans=0;
	cin >> n >> k;
	for (i = 1; i <= k; i++) {
		cin >> d;
		for (j = 1; j <= d; j++) {
			cin >> t;
			c[t]++;
		}
	}
	for (i = 1; i <= n; i++) {
		if (c[i] == 0)ans++;
	}
	cout << ans << endl;
}

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

int a,b,c,ans; 
char s[110],t[110];

inline int read(){
  	int X=0,w=0; 
	char ch=0;
  	while (ch<'0' || ch>'9'){
		w|=ch=='-';
		ch=getchar();
	}
  	while (ch>='0' && ch<='9') 
	    X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  	return w?-X:X;
}

int main(){
	/*scanf("%d%d%d",&a,&b,&c);
	ans=min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c));
	ans=min(ans,abs(b-a)+abs(c-a));
	ans=min(ans,abs(c-b)+abs(a-c));
	ans=min(ans,abs(a-c)+abs(b-a));
	ans=min(ans,abs(b-c)+abs(a-b));
	printf("%d",ans);*/
	scanf("%s%s",s,t);
	int len=strlen(s);
	for (int i=0;i<len;i++)
	  	for (int j=0;j<len;j++){
	  		int k=i+j;
			if (k>=len) k-=len;
			if (s[k]!=t[j]) break;
			if (j==len-1){
				printf("Yes");
				return 0;
			}
	  	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

int main(){
//int W,H,x,y,r;
    int x,y;
    cin>>x>>y;
  
    while(!(x==0 && y==0)){   
    if(x>y){
    swap(x,y);    
    }
    cout<<x<<" "<<y<<"\n";    
 
    cin>>x>>y;
    
    }
  return 0;
}


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

using namespace std;

int main() {
    vector<bool> isprime(10001, true);
    isprime[0] = isprime[1] = false;
    for(int i = 2; i <= 100; ++i) {
        if(!isprime[i]) continue;
        for(int j = i*i; j < isprime.size(); j += i) isprime[j] = false;
    }

    while(true) {
        int N;
        cin >> N;
        if(cin.eof()) break;

        int cnt = 0;
        for(int i = 1; i <= N; ++i) {
            if(isprime[i] && isprime[N+1-i]) ++cnt;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int n;
	int tmp;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			printf(" %d", i);
			
		}else {
			tmp = i;
			for (;;) {
				if (tmp == 0)break;
				if (tmp % 10 == 3) {
					printf(" %d", i);
					break;
				}
				tmp /= 10;
				

			}

			
		}
	}
	printf("\n");

	//system("pause");
	return 0;
}


Measured memory_bytes: 3208
import java.util.Scanner;

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

		long a = sc.nextLong();

		long b = sc.nextLong();
		long min = b;
		long max = b;
		long total = b;

			for(int i = 2; i <= a; i++) {
				b = sc.nextLong();

				if(min > b) {
					min = b;
				}
				if(max < b) {
					max = b;
				}
				total = total + b;
			}

			System.out.println(min + " " + max + " " + total);
	}
}

Measured memory_bytes: 41784
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int p, q, r;
	cin >> p >> q >> r;
	cout << min(p+q, min(p+r, q+r)) << endl;
	return 0;
}


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

int N, Q;

vector<vector<int>> graph(0, vector<int>());


void rOp(int v, int p, vector<ll> & score){
    if(p != -1) score[v] += score[p];
    for (auto elem : graph[v])
    {
        if(elem == p) continue;
        rOp(elem, v, score);
    }
}

int main(void)
{
    cin >> N >> Q;
    graph.resize(N);
    vector<ll> ans(N);

    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    
    for (int i = 0; i < Q; i++)
    {
        int p, x;
        cin >> p >> x;
        ans[p-1] += (ll) x;
    }

    rOp(0, -1, ans);

    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 25148
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	// cout<< LLINF << endl;

	long long a; cin >> a;
	string b; cin >> b;
	string c;
	c.push_back(b[0]);
	c.push_back(b[2]);
	c.push_back(b[3]);
	long long e = stoll(c);
	long long d = a * e;
	if(d < 100){
		cout << 0 << endl;
		return 0;
	}
	long long ans = d / 100LL;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <functional>
#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 int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int p[3];
struct K {
  ll x, y, z;
  ll calc(void) const {
    return x * p[0] + y * p[1] + z * p[2];
  }
};
bool operator<(const K& k1, const K& k2) {
  return k1.calc() < k2.calc();
}

K vs[1000+10];

int main(void) {
  int N, M;
  scanf("%d%d", &N, &M);
  REP(i, N) {
    scanf("%lld%lld%lld", &vs[i].x, &vs[i].y, &vs[i].z);
  }
  ll res = 0;
  REP(pat, 8) {
    REP(i, 3) {
      if(pat & (1 << i)) {
        p[i] = 1;
      } else {
        p[i] = -1;
      }
    }
    sort(vs, vs + N);
    reverse(vs, vs + N);
    K cur = {0, 0, 0};
    REP(i, M) {
      cur.x += vs[i].x;
      cur.y += vs[i].y;
      cur.z += vs[i].z;
    }
    res = max(res, cur.calc());
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	llint a, b, x;
	cin >> a >> b >> x;
	llint ans = b / x - a / x;
	if (a%x == 0) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <map>
using namespace std;

int main()
{
	long long N,A,B,C,D,E;
	cin >> N >> A >> B >> C >> D >> E;
	long long min = A;
	if (min > B) min = B;
	if (min > C) min = C;
	if (min > D) min = D;
	if (min > E) min = E;
	cout << (N-1) / min + 5 << endl;
	return 0;
}

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

int main ()
{
    int num1 , num2 , num3 , sum = 0 ;

    cin >> num1 >> num2 >> num3 ;

    sum = num1 + num2 + num3 ;

    if (sum >= 22 )
    {
        cout << "bust" << endl ;
    }
    else if (sum < 22 )
    {
        cout << "win" << endl ;
    }

    return 0 ;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans=1,m;
int a[100000+10],cnt;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(x!=a[cnt])a[++cnt]=x;
	}
	for(int i=2;i<cnt;i++){
		if(a[i]>a[i-1]&&a[i]>a[i+1])i++,ans++;
		else if(a[i]<a[i-1]&&a[i]<a[i+1])i++,ans++;
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

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

    double d = L / 3.0;
    cout << fixed << setprecision(10);
    cout << d * d * d << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

int main(){
    double a,b,c,deg;
    double rad;

    std::cin>>a>>b>>deg;

    rad = deg * M_PI / 180;

    double s = a*b*sin(rad)/2;
    double h = b*sin(rad);

    c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(rad));
    double l = a + b + c;
    
    printf("%f\n%f\n%f\n", s, l, h);
    return 0;

}



Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n , k ;
    cin >> n >> k ;
    int arr[n] , index[n] ;
    for(int i = 0 ; i < n ; i++){
        cin >> arr[i] ;
            index[i] = i+1;
    }
    for(int i = 0 ; i < n ; i++){
        int min_index = i ;
        for(int j = i ; j < n ; j++)
            if(arr[j] < arr[min_index])
                min_index = j ;
        swap(arr[i] , arr[min_index]);
        swap(index[i] , index[min_index]);
    }
    int ans = 0 ;
    for(int i = 0 ; i < k ; i++)
        ans+=arr[i] ;
    cout << ans ;
}


Measured memory_bytes: 3616
n,m = map(int,input().split())

req = []
for i in range(m):
    a,b = map(int,input().split())
    req.append([a,b])
req.sort(key=lambda x:x[1])
bef = -1
ans = 0
# print(req)
for i in range(m):
    if req[i][0] > bef:
        ans += 1
        bef = req[i][1]-1
    # print(bef,ans)

print(ans)


Measured memory_bytes: 21340
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
int main()
{
	ll K,N,Max=0,ANS=0;
	vector<ll>V;
	cin>>K>>N;
	rep(i,N){
		ll t;
		cin>>t;
		V.push_back(t);
	}
	rep(i,N){
		ll t;
		if(i!=N-1){
			t=V[i+1]-V[i];
		}
		else{
			t=K-V[i]+V[0];
		}
		ANS=ANS+t;
		//cout<<ANS<<endl;
		if(Max<=t)Max=t;
	}
	cout<<ANS-Max<<endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n, m, ans = 0;;
	cin >> n >> m;
	if(n * 2 <= m) {
		ans = n;
		m -= n * 2;
		ans += m / 4;
	} else  {
		ans = m / 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {
	
	char a;

	cin >> a;

	int A = a + 1;

	a = A;

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <iostream>
#define ll long long
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy" << "\n";
	else if (s == "Cloudy")
		cout << "Rainy" << "\n";
	else
		cout << "Sunny" << "\n";
}

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

int main() {
  
  // 入力
  
  long long N, K;
  cin >> N >> K;
  
  long long S = 0;
  
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    S += A[i];
  }
  
  // 約数のリスト(大きい順)
  
  vector<long long> div;
  long long i = 1;
  while (i * i < S) {
    if (S % i == 0) {
      div.push_back(i);
      div.push_back(S / i);
    }
    i++;
  }
  
  if (i * i == S) div.push_back(i);
  
  sort(div.begin(), div.end());
  reverse(div.begin(), div.end());
  
  // 大きいものから可能か調べて出力
  
  for (long long i = 0; ; i++) {
    
    long long d = div[i];
    vector<long long> rem(N);
    
    long long R = 0;
    
    for(long long j = 0; j < N; j++) {
      rem[j] = A[j] % d;
      R += rem[j];
    }
    
    sort(rem.begin(), rem.end());
    
    long long x = R / d;
    long long ans = 0;
    
    for (long long j = 0; j < N - x; j++) {
      ans += rem[j];
    }
    
    if (ans <= K) {
      cout << d << endl;
      break;
    }
    
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#define pb push_back
using namespace std;
const int MAX = 11000; 
bool prime[MAX];
typedef pair<int,int> P;
vector<P> vec;
void eratos(){
  for(int i=0;i<MAX;i++)prime[i] = false;
  for(int i=3;i<MAX;i+=2)prime[i] = true;
  prime[2] = true;
  int lim = (int)sqrt((double)MAX)+1;
  for(int i=3;i<=lim;i+=2){
    if(!prime[i])continue;
    for(int j=i+i;j<MAX;j+=i)prime[j] = false;
  }

  for(int i=2;i<MAX;i++){
    if(prime[i] && prime[i+2]){
      vec.pb(P(i,i+2));
    }
  }

}
 
int main(){
  int n,q;
  eratos();
  while(true){
    cin >> n;
    if(n == 0)break;
    for(int i = 0;i<vec.size();i++){
      if(vec[i].second > n){
	cout << vec[i-1].first << " " << vec[i-1].second << endl;
	break;
      }
    }   

  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    string s;
    cin >> s;
    set<int> se;
    rep(i,s.length()) {
        se.insert(s[i]);
    }
    if (se.size() == s.length()) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    return 0;
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int n,x,y,z;

bool trim(deque<int>& H){ // return true if H is xyz
	int sum=0,i=0;
	while(i<H.size()){
		if(sum+H[i]>x){
			if(i>0){
				sum-=H.front();
				i--;
			}
			H.pop_front();
			continue;
		}
		sum+=H[i];
		i++;
		if(sum==x) break;
	}
	if(i==H.size()) return false;

	sum=0;
	while(i<H.size()){
		if(sum+H[i]>y){
			H.pop_front();
			return trim(H);
		}
		sum+=H[i];
		i++;
		if(sum==y) break;
	}
	if(i==H.size()) return false;

	sum=0;
	while(i<H.size()){
		if(sum+H[i]>z){
			H.pop_front();
			return trim(H);
		}
		sum+=H[i];
		i++;
		if(sum==z) return true;
	}
	return false;
}

map<deque<int>,mint> memo[40][18];

mint dfs(int i,deque<int> H){
	if(i==n) return 1;

	int m=H.size();
	if(memo[i][m].count(H)==1) return memo[i][m][H];

	mint res=0;
	deque<int> H2;
	for(int a=1;a<=7;a++){
		H2.assign(H.begin(),H.end());
		H2.emplace_back(a);
		if(!trim(H2)) res+=dfs(i+1,H2);
	}
	res+=dfs(i+1,{})*3; // 8, 9, 10
	return memo[i][m][H]=res;
}

int main(){
	cin>>n>>x>>y>>z;
	cout<<pow(mint(10),n)-dfs(0,{})<<'\n';
	return 0;
}


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

using namespace std;


int main() {

    int a,b;
    cin>>a>>b;

    int tmpA,tmpB;
    int ans = -1;

    for (int i=1;i<1010;i++){

        tmpA = floor((double)i*0.08);
        tmpB = floor((double)i*0.1);

        if(tmpA == a && tmpB == b){
            ans = i;
            break;
        }
    }


        cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.range, std.algorithm, std.conv, std.string, std.array, std.typecons, std.format;

void main() {
    long n;
    long ans = 0;
    readf("%d", &n);

    for (long i = 1; i < n; i++) {
        long q = (n - i) / i;
        long r = (n - i) % i;
        if (i >= q) {
            break;
        }
        if (r == 0) {
            // writeln(q);
            ans += q;
        }
    }
    writeln(ans);

    /*
    long naive = 0;
    for (long i = 1; i < n; i++) {
        if (n / i == n % i) {
            writefln("[%d]*%d + %d = %d", i, n/i, n%i, n);
            naive += i;
        } else {
            writefln("%d*%d + %d = %d", i, n/i, n%i, n);
        }
    }
    writeln(naive);
    */

}



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

typedef long long ll;

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

    int n;
    cin >> n;

    int cnt = 0;

    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        if(x != i) cnt++;
    }

    cout << (cnt <= 2 ? "YES" : "NO") << endl;
}

/**
*/


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

int main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 ll n;
 cin>>n;
 ll arr[n];
 map<ll,ll>mp;
 for(int i=0;i<n;i++) {
     cin>>arr[i];
     ++mp[arr[i]];
 }
 ll ans=0;
 for(auto i : mp ) {
     ans+=((i.second*(i.second-1))/2);
    // cout<<i.first<<" "<<i.second<<'\n';
 }
 for(int i=0;i<n;i++) {
     ans-=((mp[arr[i]]*(mp[arr[i]]-1))/2);
     ll z=mp[arr[i]];
     if(z>1) {
         z--;
         ll ans1=ans+((z*(z-1))/2);
         cout<<ans1<<'\n';
     }
     else
     cout<<ans<<'\n';
      ans+=((mp[arr[i]]*(mp[arr[i]]-1))/2);
 }
 
}

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

typedef long long ll;
const int INF = 1e9 + 7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,n;
  cin >> h >> n;
  vector<int> dp(h+1,INF);
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    int a,b;
    cin >> a >> b;
    for(int j = 0; j < h; j++){
      int nj = min(j+a,h);
      dp[nj] = min(dp[nj],dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long k = sc.nextLong();

    int[] a = new int[n];

    int sum = 0;
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      sum += a[i];
    }

    for (int divS = 1; divS <= sum; divS++) {
      if (sum % divS != 0) continue;
      int divL = sum / divS;
      if (isValid(divL, k, n, a)) {
        os.println(divL);
        return;
      }
    }
  }

  private static boolean isValid(int d, long k, int n, int[] a) {
    int[] rest = new int[n];
    for (int i = 0; i < n; i++) {
      int r = a[i] % d;
      rest[i] = r;
      if (k < r && k < d - r) return false;
    }

    int count = 0;
    Arrays.sort(rest);
    int remain = 0;
    int l = 0;
    int r = n - 1;
    while(l <= r) {
      if (0 <= remain) {
        int val = rest[r];
        remain += val - d;
        count += d - val;
        r--;
      } else {
        int val = rest[l];
        remain += val;
        count += val;
        l++;
      }
    }
    return count <= 2 * k;
  }
}

Measured memory_bytes: 27316
#include<stdio.h>

int main()
{
    int a,b,r;
    char t;
    scanf("%d %c %d",&a,&t,&b);
    if(t == '+'){
        r=a+b;
        printf("%d",r);
    }
    else if(t == '-'){
        r=a-b;
        printf("%d",r);
    }
}


Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 998244353;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let (n,s) = read!(usize,usize);
	let a = read!([usize]);
	let mut dp = vec![vec![0;3010];n+1];
	dp[0][0] = 1;
	for i in 0..n {
		for j in 0..3001 {
			dp[i+1][j] += 2*dp[i][j];
			dp[i+1][j] %= MOD;
			let val = a[i]+j;
			if val>3000 {
				continue;
			}
			dp[i+1][val] += dp[i][j];
			dp[i+1][val] %= MOD;
		}
	}
	println!("{}",dp[n][s]);
}

fn run() {
    solve();
}


Measured memory_bytes: 71560
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

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

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> nums(n);
    for(int i = 0; i < n; ++i){
        cin >> nums[i];
    }
    int max = 0;
    max = (k - nums[n-1]) + nums[0];
    for(int i = 1; i < n; ++i){
        int tmp = nums[i] - nums[i-1];
        if(max <= tmp){
            max = tmp;
        }
    }
    cout << k - max << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    int A,B,count=0;
    cin>>A>>B;
        for(int i=A;i<=B;i++){
            int x=i%10;
            int y=i%100/10;
            int z=i%10000/1000;
            int w=i/10000;
            if(x==w&&y==z)count++;
        }
    cout<<count;
}

Measured memory_bytes: 3160
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    s = [input() for _ in range(n)]
    m = I()
    t = [input() for _ in range(m)]
    word = set(s) | set(t)
    ans = 0
    for w in word:
        cnt = s.count(w)
        cnt -= t.count(w)
        ans = max(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      long k = scanner.nextLong();
      long s = scanner.nextLong();
      long ans = 0;
      for (long x = 0; x <= k; x++) {
        for (long y = 0; y <= k; y++) {
          long z = s - x - y;
          if (0 <= z && z <= k) ans++;
        }
      }
      
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 35824
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	return scanInt(sc)
}

func resolve(n int) int {
	max := 0
	for i := 1; i+1 <= n; i++ {
		max += i
	}
	// for p := range permutations(n) {
	// 	v := 0
	// 	for i, n := range p {
	// 		v += (i + 1) % (n + 1)
	// 	}
	// 	if max < v {
	// 		max = v
	// 	}
	// }
	return max
}

func permutations(l int) chan []int {
	ch := make(chan []int)
	go func() {
		dfsPermutations(0, make([]bool, l), []int{}, func(perm []int) bool {
			p := make([]int, len(perm))
			copy(p, perm)
			ch <- p
			return false
		})
		close(ch)
	}()
	return ch
}

func dfsPermutations(pos int, used []bool, perm []int, atLeaf func(perm []int) (halt bool)) (halt bool) {
	l := len(used)
	if pos == l {
		if atLeaf(perm) {
			return true
		}
	}

	for i := 0; i < l; i++ {
		if used[i] {
			continue
		}
		used[i] = true
		if dfsPermutations(pos+1, used, append(perm, i), atLeaf) {
			return true
		}
		used[i] = false
	}
	return false
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1796
def main():
    H, W = map(int, input().split())
    board = [list(input()) for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if board[i][j] == ".":
                count = 0
                for k in range(-1, 2):
                    for l in range(-1, 2):
                        if 0 <= i + k < H and 0 <= j + l < W:
                            if board[i + k][j + l] == "#":
                                count += 1
                board[i][j] = str(count)
    for i in range(H):
        print("".join(map(str, board[i])))
main()

Measured memory_bytes: 41200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, Ma, Mb;
    int[] a, b, c;
    const int INF = 1234567890;
    void Solve() {
        //intput
        N = io.Int;
        Ma = io.Int;
        Mb = io.Int;
        a = new int[N];
        b = new int[N];
        c = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = io.Int;
            b[i] = io.Int;
            c[i] = io.Int;
        }
        //cal
        var dp = new int[401, 401];
        for (int i = 0; i < dp.GetLength(0); ++i)
            for (int j = 0; j < dp.GetLength(1); ++j)
                dp[i, j] = INF;
        dp[0, 0] = 0;
        for (int i = 0; i < N;++i)
            for (int j = dp.GetLength(0)-1; j >= 0;--j)
                for (int k = dp.GetLength(1) - 1; k >=0;--k)
                    if (dp[j,k]!=INF)
                        dp[j + a[i], k + b[i]] = 
                            Math.Min(dp[j + a[i], k + b[i]], dp[j, k] + c[i]);
        int ans = INF;
        for (int i = 1; i < 401; ++i)
            for (int j = 0; j < 401; ++j)
                if (i * Mb == j * Ma)
                    ans = Math.Min(ans, dp[i, j]);
        //res
        Console.WriteLine(ans == INF ? -1 : ans);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 11616
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
#define pi 3.1415926535
using namespace std;

int main(void){
    ll n;cin>>n;
    vl a(n,0);
    rep(i,n-1){
        ll x;cin>>x;
        x--;
        a[x]++;
    }
    rep(i,n) cout<<a[i]<<endl;
}


Measured memory_bytes: 4844
#include <stdio.h>

int depth(int);




struct Node{
  int parent,leftchild,rightbro;//左子右兄弟表現
};

struct Node node[100001];


int main(){

  int i,j,mom,k,n,child,x,bro;

  scanf("%d",&n);//number of node

  for(i = 0 ; i < n ; i++){
    node[i].parent = -1;
    node[i].leftchild = -1;
    node[i].rightbro = -1;
  }


  for(i = 0 ; i < n ; i++){//各nodeの入力
    scanf("%d %d",&mom,&k);
   
    for(j = 0 ; j < k ; j++){
      scanf("%d",&child);
      
      if(j == 0){
	node[mom].leftchild =child;
	node[child].parent = mom;
	x = child;
 }
      else{
	node[x].rightbro = child;
	node[child].parent = mom;
	x = child;
      }
    }
  }
  for(i = 0 ; i < n ; i++)
    {
      printf("node %d: parent = %d, depth = %d, ",i , node[i].parent,depth(i));
      if(node[i].leftchild == -1 && node[i].parent!= -1)printf("leaf, ");
      else if(node[i].parent == -1)printf("root, ");
      else if(node[i].leftchild != -1)printf("internal node, ");

      printf("[");

      if(node[i].leftchild != -1){

	printf("%d",node[i].leftchild);

	bro = node[i].leftchild;

	while(1){
	  if(node[bro].rightbro == -1)break;
	  printf(", %d",node[bro].rightbro);
	  bro = node[bro].rightbro;
	}
      }

      printf("]\n");
    }

  return 0;
}
int depth(int k){
  int dep = 0;
  for(dep = 0 ; node[k].parent != -1 ; dep++){
    k = node[k].parent;
  }
  return dep;
}

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//小数点以下　cout << fixed << setprecision(10) << num << endl;

int main(){
    int d; ll g;
    cin >> d >> g;
    int p[d],c[d];
    rep(i,d){
        cin >> p[i] >> c[i];
    }
    //問題数のオーダーが１０００
    //解く問題を決め打ち(2^10) そのうち完全に解く問題を決め打ち(2^10)
    int ans = 1001001001;
    rep(i,(1<<d)){
        bool ok[d];
        rep(j,d){
            if(i&(1<<j)) ok[j]=1;
            else ok[j]=0;
        }
        //問題ok[j]たちを使う。解き切らない問題を一つ決める
        rep(j,d){
            if(!ok[j]) continue;
            ok[j]=0;
            ll res = 0;
            int num = 0;
            rep(k,d){
                if(ok[k]){
                    res += p[k]*100*(k+1)+c[k];
                    num += p[k];
                }
            }
            if(res>=g){
                ans=min(ans,num);
                continue;
            }
            int num2 = 0;
            while(res < g){
                num2++;
                num++;
                res+=(j+1)*100;
                if(num2==p[j]) res+=c[j];
                if(num2>p[j]){
                    num=11451419;
                    break;
                }
            }
            ans=min(ans,num);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

map<char, vi> m;

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < s.ln; i++) {
        m[s[i]].pb(i + 1);
    }

    ll ans = 0;
    int pi = 0;

    for (int i = 0; i < t.ln; i++) {
        if ((int)m[t[i]].sz == 0) {
            cout << -1;
            return 0;
        }
        int k = ub(m[t[i]].B, m[t[i]].E, pi) - m[t[i]].B;
        if (k == m[t[i]].sz) {
            ans += s.ln - pi + m[t[i]][0];
            pi = m[t[i]][0];
        } else {
            ans += m[t[i]][k] - pi;
            pi = m[t[i]][k];
        }
    }

    cout << ans;

    return 0;
}


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

string name[1002];
int base[1002], west[1002];

int main(){
  int n, m;

  while(cin >> n >> m, n || m){
    for(int i = 0; i < n; i++){
      cin >> name[i] >> base[i] >> west[i];
    }
    for(int i = 0; i < m; i++){
      int x;
      cin >> x;

      bool flg = false;

      for(int j = 0; j < n; j++){
        int base_west = west[j] - base[j] + 1;

        if(base_west <= x && x <= west[j]){
          flg = true;
          cout << name[j] << " " << x - base_west + 1 << endl;
          break;
        }
      }

      if(!flg) cout << "Unknown" << endl;
    }
  }
}

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

int main(){
int N,M,a,b;
  b=0;  
  vector<int> A(N);
  a=0;
  cin>>N>>M;
  for(int i=0;i<N;i++){
cin>>A.at(i);
      b+=A.at(i);
    }
  for(int i=0;i<N;i++){
  if(A.at(i)*4*M>=b){
    a++;
  }
  }
  if(a>=M){
cout<<"Yes"<<endl;
  }
  else{
cout<<"No"<<endl;
  }
}
    


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

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

  switch (D) {
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 25:
      cout << "Christmas" << endl;
      break;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int dp[3005][3005][4];
int val[3005][3005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	int k;
	cin>>k;
	int x,y,z;
	FOR(i,1,k){
		cin>>x>>y>>z;
		val[x][y]=z;
	}
	FOR(i,1,n){
		FOR(j,1,m){
			dp[i][j][0]=dp[i-1][j][3];
			FOR(k,1,3){
				dp[i][j][k]=max(dp[i][j-1][k],dp[i][j-1][k-1]+val[i][j]);
				if(k==1){
					gmax(dp[i][j][k],dp[i-1][j][3]+val[i][j]);
				}
				gmax(dp[i][j][k],dp[i][j][k-1]);
			}
		}
	}
	int ans=0;
	FOR(k,1,3){
		gmax(ans,dp[n][m][k]);
	}
	cout<<ans;
	RE 0;
}


Measured memory_bytes: 355688
uses math;
const fi='l_deque.inp';
      fo='l_deque.out';
      maxn=3000;
var n:int32;
    sum,f:array[0..maxn,0..maxn] of int64;
    a:array[1..maxn] of int32;
//=============================
procedure nhap;
var i:int32;
begin
   readln(n);
   for i:=1 to n do
   begin read(a[i]); sum[1,i]:=sum[1,i-1]+a[i]; end;
end;
//=============================
function max(x,y:int64):int64;
begin
   if x>y then exit(x)
   else exit(y);
end;
//=============================
procedure xuli;
var i,j:int32;
begin
   for i:=1 to n do
    for j:=n downto i do sum[i,j]:=sum[1,j]-sum[1,i-1];
   for i:=1 to n do f[i,i]:=a[i];
   for i:=n-1 downto 1 do
    for j:=i+1 to n do
     f[i,j]:=max(sum[i,j]-f[i+1,j],sum[i,j]-f[i,j-1]);
   write(2*f[1,n]-sum[1,n]);
end;
//=============================
begin
//   assign(input,fi); reset(input);
//   assign(output,fo); rewrite(output);
   nhap;
   xuli;
//   close(input); close(output);
end.


Measured memory_bytes: 139392
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b;
	scanf("%d%d", &a, &b);
	int bbb = b;
	int i = 0;
	while(bbb){
		bbb/=10;
		i++;
	}
	int c = a*pow(10,i)+b;
	//printf("%d\n",c);
	int t = sqrt(c);
	if(c==t*t)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

def make2d_arr(w,h,val =INF):
    return [[val]*w for i in xrange(h)]

def floyd_warshall(costs):
    N = len(costs)
    for k in xrange(N):
        for i in xrange(N):
            for j in xrange(N):
                costs[i][j]  = min(costs[i][j],costs[i][k]+costs[k][j])
    return costs

N,M = ints_raw()
costs = make2d_arr(N+1,N+1,INF)
E = []
for i in xrange(M):
    a,b,c = ints_raw()
    E.append((a,b,c))
    costs[a][b]=c
    costs[b][a]=c

costs = floyd_warshall(costs)

ans  = 0
for e in E:
    if costs[e[0]][e[1]] < e[2]:
        ans+=1
print ans






Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b >= c){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}

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

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

int main() {
    int n; cin >> n;
    vector<int> p(n), q(n); 
    rep(i, n){
        cin >> p[i];
        q[i] = p[i];
    }
    sort(q.begin(), q.end());
    if(p == q){
        cout << "YES" << endl;
        return 0;
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            swap(p[i], p[j]);
            bool flag = true;
            if(p == q){
                cout << "YES" << endl;
                return 0;
            }
            swap(p[i], p[j]);
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[110000],a[200000], b[2000000];
string str, ss, dd;
bool f,ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	ans = INF;
	rep(i, 200+1) {
		LL num = i - 100;
		sum = 0;
		rep(j, n)
			sum += (a[j] - num)* (a[j] - num);
		ans = min(sum, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560