akhauriyash/Code-Regression huggingface dataset:
import sys
N = int(input())
P = [[] for _ in range(N)]
for i in range(N):
    a = int(input())
    for _ in range(a):
        x, y = map(int, sys.stdin.readline().split())
        P[i].append((x - 1, y))

ans = 0
for pattern in range(1 << N):
    ok = True
    count = 0
    for i in range(N):
        if pattern & (1 << i):
            count += 1
            for x, y in P[i]:
                if y == 1:
                    if not pattern & (1 << x):
                        ok = False
                        break
                else:
                    if pattern & (1 << x):
                        ok = False
                        break
        if not ok:
            break
    if ok:
        ans = max(ans, count)
print(ans)

Measured memory_bytes: 9232
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
LCM = A[0]
for i in range(1, N):
    LCM = LCM * A[i] // math.gcd(LCM, A[i])

for i in range(N):
  temp = LCM//A[i]
  if temp%2 == 0: #存在しない
    print(0)
    exit()
MIN = LCM//2
nokori = M - MIN
#print(MIN,nokori,LCM)
ans = nokori//LCM + 1
print(ans)



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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(t) (int)t.size()

typedef long long lint;
typedef pair<int, int> pii;

int n;
string group[110];

vector<string> split_all(string s, string t) {
	vector<string> res;
	for (int p = 0; (p = s.find(t)) != -1;) {
		res.push_back(s.substr(0, p));
		s = s.substr(p + size_of(t));
	}
	res.push_back(s);
	return res;
}

string gname[110];
vector<string> g_member[110];

set<string> ans;
bool look[110];

void rec(int i) {
	if (look[i]) return;
	look[i] = true;
	
	int g_size = g_member[i].size();
	
	for_(j,0,g_size) {
		string member = g_member[i][j];
		bool flag = false;
		
		for_(k,0,n) {
			if (gname[k] == member) {
				rec(k);
				flag = true;
				break;
			}
		}
		
		if (!flag) ans.insert(member);
	}
}

void solve() {
	for_(i,0,n) {
		vector<string> split = split_all(group[i], ":");
		gname[i] = split[0];
		g_member[i] = split_all(split[1].substr(0, size_of(split[1]) - 1), ",");
	}
	
	ans.clear();
	minit(look, 0);
	rec(0);
	
	cout << size_of(ans) << endl;
}

int main() {
	while (cin >> n , n) {
		for_(i,0,n) cin >> group[i];
		solve();
	}
	return 0;
}

Measured memory_bytes: 1368
N, x = map(int, input().split())
a = list(map(int, input().split()))

out = 0
for i in range(N-1):
    out = out + max( 0, a[i] + a[i+1] - x)
    if i == 0:
        a[0] = min( a[0], x )
        a[1] = min( a[1], x - a[0] )
    else:
        a[i+1] = min( a[i+1], x - a[i] )
        
print(out)


Measured memory_bytes: 14592
N = int(input())
A = [int(i) for i in input().split()]

box = [0] * N
for i in range(N - 1, -1, -1):
    cnt = 0
    num = i + 1
    while num <= N:
        cnt += box[num - 1]
        num += i + 1
    
    if cnt % 2 != A[i]:
        box[i] = 1
    
ans = [idx + 1 for idx in range(N) if box[idx]]

print(len(ans))
print(*ans)

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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int ans = 0;
    for(int i = n-1; i >= 0; i--){
        bool visible = true;
        for(int j = i-1; j >= 0; j--){
            if(h[i] < h[j]){
                visible = false;
                break;
            }
        }
        if(visible){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define LL long long

struct edge{
    int to, cost;
};
struct node{
    int n, cost;
    bool operator<(const node & n1) const {
        return n1.cost < cost;
    }
};
int N, M, K;
int a[100010], b[100010], l[100010];
vector<edge> G[3010];
int main(){
    cin >> N >> M >> K;
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i] >> l[i];
        G[a[i]].push_back(edge{b[i], l[i]});
        G[b[i]].push_back(edge{a[i], l[i]});
    }
    int D[3010] = {};
    fill(D, D + (N + 1), 1 << 30);
    priority_queue<node> pq;
    for(int i = 0; i < K; i++){
        int c = 0;
        cin >> c;
        D[c] = 0;
        pq.push(node{c, 0});
    }
    while(!pq.empty()){
        node n = pq.top();
        pq.pop();
        if(D[n.n] < n.cost) continue;
        for(auto u : G[n.n]){
            int c = n.cost + u.cost;
            if(c < D[u.to]){
                D[u.to] = c;
                pq.push(node{u.to, c});
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        int cost = (D[a[i]] + D[b[i]] + l[i] + 1) / 2;
        ans = max(cost, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7124
#include<stdio.h>
#include<math.h>
 
int main(){
    unsigned int a,b;
    while(~scanf("%u%u",&a,&b)){
        unsigned int c=a,d=b;
        while(a>0&&b>0){
            if(a>b)a=a%b;
            else b=b%a;
        }
        printf("%u %u\n",a+b,c/(a+b)*d);
    }
}


Measured memory_bytes: 2756
#include <stdio.h>
int main(void){
    int H,W,i,j;
    
    for(;;){
        scanf("%d %d",&H,&W);
        if(H+W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if(j==W-1){
                    printf("#\n");
                }else{
                    printf("#");
                }
            }
        }
        printf("\n");
    }
    
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  ll ans=0;
  ireps(i,k,n+1){
    ll min=i*(i-1)/2;
    ll max=(n+1)*n/2-(n-i+1)*(n-i)/2;
    // cout<<min<<' '<<max<<endl;
    (ans+=(max-min+1)%MOD)%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[11111][11111];
long long u[11111110];
int o[11111111];
int y[11111][11111];
int oo[1111111],yy[11111][11111],ii[11111][11111],uu[1111111];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  int r=0,gg=0,hh=0,ee=0;
  string s[11111];
  cin >>a>>b>>c>>d;
  for(int n=0;n<a;n++){
    f=0,g=0,h=0,j=0;
    for(int m=0;m<b;m++){
      if(f<c&&u[m]<d) i[n][m]++,f++,u[m]++;
      if(g<c&&o[m]<a-d) y[n][m]++,g++,o[m]++;
      if(h<b-c&&oo[m]<a-d) yy[n][m]++,h++,oo[m]++;
      if(j<b-c&&uu[m]<d) ii[n][m]++,j++,uu[m]++;
    }
    if(f!=c&&f!=b-c) r++;
    if(g!=c&&g!=b-c) ee++;
    if(h!=b-c&&h!=c) gg++;
    if(j!=b-c&&j!=c) hh++;
  }
  for(int n=0;n<b;n++){
    if(o[n]!=a-d&&o[n]!=d) ee++;
    if(u[n]!=d&&u[n]!=a-d) r++;
    if(oo[n]!=a-d&&oo[n]!=d) gg++;
    if(uu[n]!=d&&uu[n]!=a-d) hh++;
  }
  if(ee==0){
    for(int n=0;n<a;n++){
      for(int m=0;m<b;m++) cout <<y[n][m];
      cout <<'\n';
    }
  }
  else{
    if(r==0){
      for(int n=0;n<a;n++){
	for(int m=0;m<b;m++) cout <<i[n][m];
	cout <<'\n';
      }
    }
    else{
      if(gg==0){
	for(int n=0;n<a;n++){
	  for(int m=0;m<b;m++) cout <<yy[n][m];
	  cout <<'\n';
	}
      }
      else{
	if(hh==0){
	  for(int n=0;n<a;n++){
	    for(int m=0;m<b;m++) cout <<ii[n][m];
	    cout <<'\n';
	  }
	}
	else cout <<"No\n";
      }
    }
  }
  return (0);
}


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

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i=0; i<m; i++) cin >> b.at(i);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i=0; i < n; i++){
        for (int j=0; j < m; j++) cin >> a.at(i).at(j);
    }
    
    int num=0;

    vector<int> sum(n,c);

    for (int i=0; i < n; i++){
        for (int j=0; j < m; j++){
        sum.at(i)+=a.at(i).at(j)*b.at(j);
        }
        if (sum.at(i) > 0) {
            num++;
        }
    }

    cout << num << endl;
    
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int H1,M1,H2,M2,K;
    cin>>H1>>M1>>H2>>M2>>K;
    int up=(H2-H1)*60+(M2-M1);
    cout<<max(up-K,0)<<"\n";
 	return 0;
}

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

const int N = 200005;

int n, k;
int a[N];

bool check(int len) {
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += (a[i] + len-1) / len - 1;
  }

  return sum <= k;
}

int solve() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  int l = 1, r = 1000000000;
  int ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }

  printf("%d\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 4532
/// 20-01-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(x)

using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<pii> vpll;
typedef pair<ll,ll> Pll;
typedef map<string,int>msi;
typedef set<ll>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}

///-------------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	int n,m;
	r(n,m);
	cout<<(n-1)*(m-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 9; i > 0; i-- {
		for j := 9; j > 0; j-- {
			if i*j == n {
				fmt.Println("Yes")
				return
			} else if i*j < n {
				break
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys

def solve(N: int, K: int):
    k = (N - 1) * (N - 2) // 2
    if k < K:
        return None
    edges = [(1, i) for i in range(2, N+1)]
    def f():
        for i in range(2, N+1):
            for j in range(i+1, N+1):
                yield i, j
    it = f()
    while k > K:
        edges.append(next(it))
        k -= 1
    return edges

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    edges = solve(N, K)
    if edges:
        print(len(edges))
        for e in edges:
            print(*e)
    else:
        print(-1)

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main()


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

int main()
{
      int A[3][3];
      for(int i=0; i<3; i++)
        for(int j=0; j<3; j++)
          cin>>A[i][j];
        //cout<<"GHJ";
      int n;
      cin>>n;
      int k;
      while(n--)
      {
          cin>>k;
          for(int p=0; p<3; p++)
            for(int q=0; q<3; q++)
          {
              if(A[p][q]==k)
              {
                  A[p][q]=0;
                  //break;
              }
          }
      }
        if(A[0][0] + A[0][1] + A[0][2] == 0)
         cout<<"Yes";
      else if(A[1][0] + A[1][1] + A[1][2] == 0)
         cout<<"Yes";
        else if(A[2][0] + A[2][1] + A[2][2] == 0)
            cout<<"Yes";
         else if(A[0][0] + A[1][0] + A[2][0] == 0)
            cout<<"Yes";
        else if(A[0][1] + A[1][1] + A[2][1] == 0)
            cout<<"Yes";
        else if(A[0][2] + A[1][2] + A[2][2] == 0)
            cout<<"Yes";
        else if(A[0][0]+A[1][1]+A[2][2]==0)
            cout<<"Yes";
        else if(A[0][2]+A[1][1]+A[2][0]==0)
            cout<<"Yes";
        else
            cout<<"No";

        return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long int
using namespace std;
int main(){
	ull a, b, c;
	cin >> a;
	if (a == 1) 	cout << "Hello World" << endl;
	else {
		cin >> b >> c;
		cout << b + c<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[10];
  int sum=0;
  for(int i=0; i<6; i++){
    cin >> a[i];
    sum += a[i];
  }
  int mini = 1000;
  for(int i=0; i<4; i++){
    mini = min(a[i],mini);
  }
  //cout << mini << endl;
  sum -= mini;
  mini = 1000;
  for(int i=4; i<6; i++){
    mini = min(a[i],mini);
  }
  //cout << mini << endl;
  sum -= mini;
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3076
K = int(input())
import math
b_list=[]
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            a=math.gcd(i,j)
            b=math.gcd(a,k)
            b_list.append(b)
print(sum(b_list))

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

int main() {
  int i;
  cin >> i;
  int a[i];
  for(int j=0;j<i;j++){
    cin >> a[j];
  }
  for(int k=i-1;k>=0;k--){
    cout << a[k];
    if(k!=0){
      cout << ' ';
    }
    if(k==0){
      cout << endl;
    }
  }
}


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

int main(void)
{	
	int count = 0;
	int i;
	long num;
	char str[20],str1[200][15], str2[200][15];
	char *p;
	
	for(i=0; i<200; i++){
		scanf("%s %s", &str1[i], &str2[i]);
		//gets(str1[i]);
		if( *str1[i]=='\0' || *str1[i]=='\n') break;	
		
		num = atol(str1[i])+atol(str2[i]);
		//ltoa(num, str, 10);
		
		sprintf(str,"%ld",num);
		//sprintf(num,"%ld",str2[i]);
		
		//printf("%ld\n", num);
		//printf("str %s\n", str);
		
		count = 0;
		p = str;
		while(*p!='\0'){
			p++;
			count++;
		}
		printf("%d\n",count);
	
	}

	return 0;
}

Measured memory_bytes: 564
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
template <class T> void ckmax(T &x,const T y){
	if (x<y)
		x=y;
}
template <class T> void ckmin(T &x,const T y){
	if (x>y)
		x=y;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=1000005;
int n;
string s[N];
int cnt=1;
int nxt[N][26];
int val[N][26];
int ins(string s){
	vi p;
	int x=1;
	p.pb(x);
	for (auto c : s){
		int t=c-'a';
		if (!nxt[x][t])
			nxt[x][t]=++cnt;
		x=nxt[x][t];
		p.pb(x);
	}
	int res=val[p[(int)p.size()-2]][s.back()-'a'];
	int v=0;
	Fod(i,(int)p.size()-1,0){
		For(j,0,25)
			if (v>>j&1)
				val[p[i]][j]++;
		if (i>0)
			v|=1<<(s[i-1]-'a');
	}
	return res;
}
int main(){
	n=read();
	For(i,1,n){
		cin>>s[i];
		reverse(s[i].begin(),s[i].end());
	}
	sort(s+1,s+n+1,[&](string a,string b){
		return a.size()>b.size();
	});
	LL ans=0;
	For(i,1,n){
		ans+=ins(s[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 239236
#include <bits/stdc++.h>
using namespace std;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}
 
void solve(){ 
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();

    string s;cin>>s;
    int fg=0;
    rep(i,sz(s))if(s[i]=='7')fg=1;
    if(fg) cout<<"Yes\n";
    else cout<<"No\n";

	return 0;
}
 



Measured memory_bytes: 3652
//Ojas Kumar Dubey //
// el_freki //
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int md=1000000007;
#define test int t;cin>>t;while(t--)
#define f(i,j,n) for(int i=j;i<n;i++)
#define r(i,j,n) for(int i=j-1;i>=n;i--)
#define min INT_MIN
#define max INT_MAX
#define all(container) container.begin() , container.end()
#define sz(container) (int)container.size()
#define pii pair <int , int>
#define pll pair <long long int , long long int>
#define setp(x) setprecision(x)
// ------------------------------------Template End------------------------------ //
int main()
{
	fast;
	int n;
	cin>>n;
	cout<<n*n*n;
}



Measured memory_bytes: 256
class dise:
    def __init__(self, label):
        self.label1 = label[0]
        self.label2 = label[1]
        self.label3 = label[2]
        self.label4 = label[3]
        self.label5 = label[4]
        self.label6 = label[5]
    
    def N_rotation(self):
        reg = self.label1
        self.label1 = self.label2
        self.label2 = self.label6
        self.label6 = self.label5
        self.label5 = reg
        
    def E_rotation(self):
        reg = self.label1
        self.label1 = self.label4
        self.label4 = self.label6
        self.label6 = self.label3
        self.label3 = reg
        
    def S_rotation(self):
        reg = self.label1
        self.label1 = self.label5
        self.label5 = self.label6
        self.label6 = self.label2
        self.label2 = reg
        
    def W_rotation(self):
        reg = self.label1
        self.label1 = self.label3
        self.label3 = self.label6
        self.label6 = self.label4
        self.label4 = reg
    
    def right_rotation(self):
        reg = self.label2
        self.label2 = self.label3
        self.label3 = self.label5
        self.label5 = self.label4
        self.label4 = reg
    

    def search(self, value):
        while True :
            self.N_rotation()
            if value[0] == self.label1:
                break
            self.E_rotation()
            if value[0] == self.label1:
                break
            
        while True :
            self.right_rotation()
            if value[1] == self.label2:
                break
            
init_dise = input().split()
times = int(input())

for i in range(times):
    dise1 = dise(init_dise)
    order = input().split()
    dise1.search(order)
    print(dise1.label3)

Measured memory_bytes: 7728
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>
#include<cmath>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, d, ans = 0;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            int sum = 0;
            for(int k = 0; k < d; k++){
                int a = abs(x[i][k] - x[j][k]);
                sum += a * a;
            }
            int t = 1;
            while(t * t < sum){
                t++;
            }
            if(t * t == sum){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

const long long MX = 3005;


vector<bool> make(long long a, long long b) {
    vector<bool> ans(MX);
    ans[0] = 1;
    for (long long i=a; i<MX; i++)    ans[i] = ans[i] | ans[i-a];
    for (long long i=b; i<MX; i++)    ans[i] = ans[i] | ans[i-b];
    return ans;
}


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

    long long A, B, C, D, E, F;
    cin>>A>>B>>C>>D>>E>>F;

    vector<bool> waterpos = make(A, B);
    vector<bool> sugerpos = make(C, D);

    long long num = 0, denom = 100*A;
    for (long long w=1; w<MX; w++) {
        for (long long s=0; s<MX; s++) {
            long long mass = w*100+s;
            if (mass > F || s > E*w)   break;
            if (!waterpos[w] || !sugerpos[s])   continue;
            if (num*mass < denom*s)    num = s, denom = mass;
        }
    }

    cout<<denom<<" "<<num<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string S;
    cin >> S;
    for(int i = 0; i < 3; i++) {
        if(S[i] == S[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
import           Data.Char (intToDigit)

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  putStrLn $ solve a b

solve :: Int -> Int -> String
solve a b = min (replicate b a') (replicate a b') where
  a' = intToDigit a
  b' = intToDigit b


Measured memory_bytes: 508
#include <iostream>

using namespace std;

int N;
int A[100005];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	A[0] = 0; A[N + 1] = 0;

	long long int sum = 0;
	for (int i = 1; i <= N + 1; i++) {
		sum += abs(A[i] - A[i-1]);
	}

	//cout << "sum= " << sum << endl;

	for (int i = 1; i <= N; i++) {
		cout << sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i-1]) << endl;;
	}

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

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



int main(){
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	vector<bool> mid1(200010, false), mid2(200010, false);
	for(int i = 0; i < m; i++)
	{
		cin >> a[i] >> b[i];
		if(a[i] == 1) mid1[b[i]] = true;
		if(b[i] == n) mid2[a[i]] = true;
	}
	
	string ans = "IMPOSSIBLE";


	for(int i = 0; i < 200010; i++)
	{
		if(mid1[i] && mid2[i]){
			ans = "POSSIBLE";
			break;
		}
		
	}
	
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
#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> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int count = 0;
  int current = 1;
  while(current != 2 && count < n){
    current = a.at(current-1);
    count++;
  }
  if(count < n){
    cout << count << endl;
  }else{
    cout << -1 << endl;
  }
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <set>
using namespace std;

set<char> se;
int n;

int main() {
	while (cin >> n) {
		se.clear();
		for (int i = 0; i < n; ++i) {
			char c;
			cin >> c;
			se.insert(c);
		}
		if (se.size() == 4) puts("Four");
		else puts("Three");
	}
}



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

int main()
{
    bool atcoder, topcoder;
    char a[4], b[4];
    cin >> a >> b;
    if(a[0] == 'H') atcoder = true; else atcoder = false;
    if(b[0] == 'H') topcoder = true; else topcoder = false;
    if(!atcoder) topcoder = !topcoder;
    if(topcoder) cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVVll = vector<VVll>;
using VVVld = vector<VVld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  string K; cin >> K;
  int D; cin >> D;
  int n = K.size();

  VVll dp(n, Vll(D));
  dp[0][0] = 1;
  rep(i, n-1) rep(d, D) rep(k, 10) {
    (dp[i+1][(d+k)%D] += dp[i][d]) %= MOD;
  }

  int sum = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x = K[i] - '0';
    for (int d = 0; d < x; ++d) {
      int y = (sum + d) % D;
      (ans += dp[n-i-1][(D-y)%D]) %= MOD;
    }
    (sum += x) %= D;
  }

  if (sum == 0) ans++;
  (ans += MOD - 1) %= MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n][n];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
        a[i][j]=0;
  for(int i=0;i<n;i++){
    int u,k,v;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      a[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=0)cout<<" ";;
      cout<<a[i][j];
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3120
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=4e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void solve() {
	string s;
	cin>>s;
	for(int i=0; i<3; i++) {
		if(s[i]==s[i+1]) {
			cout<<"Bad"<<endl;
			return;
		}
	}
	cout<<"Good"<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

for dig in range(1, 12):
    print "? " + str(10 ** dig)
    sys.stdout.flush()
    rep = raw_input()
    if rep == "N":
        L = 10 ** (dig - 1)
        R = 10 ** dig - 1
        while R - L > 1:
            mid = (L + R) / 2
            print "? " + str(mid) + "00000"
            sys.stdout.flush()
            rep = raw_input()
            if rep == "Y":
                R = mid
            else:
                L = mid
        print "! " + str(R)
        exit()

for dig in range(1, 12):
    print "? " + str("9" * dig)
    sys.stdout.flush()
    rep = raw_input()
    if rep == "Y":
        print "! " + str(10 ** (dig - 1))
        exit()


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

int main() {
  int N,tmp;
  cin >> N;
  vector<pair<int,int>> stu(N);
  
  for(int i=0;i<N;i++){
    cin >> tmp;
    stu.at(i) = make_pair(tmp,i);
  }
  sort(stu.begin(),stu.end());
  for(int i=0;i<N;i++){
    cout << stu.at(i).second + 1;
    if(i==N-1) cout << endl;
    else cout << ' ';
  }
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std; 

int main(void) {
	int n;
	cin >> n;
	vector<double> p(n+1);
	p[0] = 1;
	for (int i = 0; i < n; ++i) {
		cin >> p[i+1];
	}
	vector<double> q(n+1);
	vector< vector<double> > sum(n+1,vector<double>(n+1));
	vector< vector<double> > dp(n+1,vector<double>(n+1,(1 << 28)));
	for (int i = 0; i < n+1; ++i) {
		cin >> q[i];
		if (i > 0) {
			dp[i][i] = p[i]+(2*(q[i-1]+q[i]));
			sum[i][i] = dp[i][i] - (q[i-1]+q[i]); 
		}
	}
	for (int i = 1; i < n+1; ++i) {
		for (int j = i+1; j < n+1; ++j) {
			sum[i][j] = sum[i][j-1] + sum[j][j] - q[j-1];
		}
	}
	double rc,left,right;
	for (int k = 2; k < n+1; ++k) {
		for (int i = 1; i < n-k+2; ++i) {
			for (int j = 0; j < k; ++j) {
				rc = dp[i+j][i+j];
				left = right = 0;
				if (j != 0) {
					rc -= 2*q[i+j-1];
					left += dp[i][i+j-1] + sum[i][i+j-1];
				}
				if (j != k-1) {
					rc -= 2*q[i+j];
					right += dp[i+j+1][i+k-1] + sum[i+j+1][i+k-1];
				}
				dp[i][i+k-1] = min(rc+left+right,dp[i][i+k-1]);
			}
		}
	}
	cout << setprecision(20) << fixed << dp[1][n] << endl;

	return 0;
}



Measured memory_bytes: 6796
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> sum(n + 1, 0);
    for(int i = 0; i + 1 < n; ++i){
        if(s[i] == 'A' && s[i + 1] == 'C')  sum[i + 2] = 1;
    }
    for(int i = 0; i < n; ++i)  sum[i + 1] += sum[i];
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l;
        int ans = sum[r] - sum[l];
        if(l > 0){
            if(s[l - 1] == 'A' && s[l] == 'C')  --ans;
        }
        cout << ans << '\n';
    }
}

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

int main(){
	long long n,k;
	cin>>n>>k;
	if(k!=0){
		n%=k;
		if(n>k-n){
			cout<<k-n;
		}
		else{
			cout<<n;
		}
	}
	else{
		cout<<n;
	}
	return 0;
}

Measured memory_bytes: 256
def val(s):
    a = [0 for i in range(26)]
    for i in s:
        a[ord(i) - ord('a')] += 1
    sum = 0;
    for i in a:
        sum = sum * 10 + i
    return sum


n = int(input())
a = []
for i in range(n):
    a.append(input())
d = {}
for i in a:
    k = val(i)
    if k in d.keys():
        d[k].append(i)
    else:
        d[k] = list()
        d[k].append(i)
sum = 0
for i in d.keys():
    sum += len(d[i]) * (len(d[i]) - 1) // 2
print(sum)


Measured memory_bytes: 32372
N = int(input())
A = list(map(int, input().split()))

if N == 0:
    if A[0] == 1:
        print (1)
        exit()
    else:
        print (-1)
        exit()


MAX = 10 ** 18
lst = [1] * (10 ** 5 + 10)

#純粋な2分木としたときの最大値
for i in range(N + 1):
    lst[i + 1] = min(MAX, lst[i] * 2)

# print (lst[:10])
for i in range(N + 1):
    tmp = lst[i] - A[i]
    if tmp < 0:
        print (-1)
        exit()
    lst[i + 1] = min(lst[i + 1], tmp * 2)

# print (lst[:10])

if lst[N] >= A[N]:
    lst[N] = A[N]
else:
    print (-1)
    exit()

# print (lst[:10])
ans = 1
tmp = 0
for i in range(N, 0, -1):
    ans += lst[i]
    lst[i - 1] = min(lst[i] + A[i - 1], lst[i - 1])

# print (lst[:10])
print (ans)


Measured memory_bytes: 20368
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 100000
int a[MAXN+5],n,app[MAXN+5];
int pos=1;
long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		app[i]=(a[i]>0);
		ans+=a[i]/2;
		a[i]%=2;
	}
	for(int i=1;i<=n;i++)
	if(a[i]&&a[i-1])ans++,a[i]=0,a[i-1]=0;
	else if(a[i-1]&&app[i])a[i]=1,a[i-1]=0;
	printf("%lld",ans);//
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <iomanip>
#include <math.h>
#include <mutex>
#include <algorithm>

//#include "test.h"

//#include "SandBox/StopRangeAccess/StopRangeAccess.h"

//#include "Data.h"


using namespace std;

typedef unsigned long ulong;
typedef unsigned long long ulolong;
typedef long long lolong;


int main()
{
	int n, m;

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		int a;
		cin >> a;

		n -= a;
	}

	if (n < 0)
	{
		cout << -1;
	}
	else
	{
		cout << n;
	}
}

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

int main() {
  int N,K,sum,x;
  cin >> N >> K;
  for (int i=0;i<N;i++) {
    cin >> x;
    if (x > K/2) sum += (K-x)*2;
    else sum += x*2;
  }
  cout << sum << endl;
}
  

Measured memory_bytes: 256
import heapq
ans = 0
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = -a[i]
heapq.heapify(a)
for i in range(m):
    b = heapq.heappop(a)
    b = -(-b//2)
    heapq.heappush(a, b)
for i in range(n):
    ans += a[i]
print(-ans)

Measured memory_bytes: 14180
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var s = ReadString();

            var ans = 700;
            foreach (var c in s) {
                if (c == 'o') ans += 100;
            }

            WriteAnswer(ans);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

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

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

set<pii> vis;
vector<pii> v;
ll ans[10];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;   
    for(int i=1;i<=n;i++){
        int a, b;
        cin >> a >> b;
        vis.insert(mp(a, b));
        for(int i=max(1, a-2);i<=a;i++){
            for(int j=max(1, b-2);j<=b;j++){
                v.eb(mp(i, j));
            }
        }
    }
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    for(int i=0;i<sz(v);i++){
        int y = v[i].fi, x = v[i].se;
        if(y <= h-2 && x <= w-2){
            int cnt = 0;
            for(int j=y;j<=y+2;j++){
                for(int k=x;k<=x+2;k++){
                    if(vis.find(mp(j, k)) != vis.end()) cnt++;
                }
            }
            ans[cnt]++;
        }
    }
    ll sum = 0;
    for(int i=1;i<10;i++) sum += ans[i];
    ans[0] += (h-2)*1ll*(w-2) - sum;
    for(int i=0;i<10;i++) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 15472
#include <bits/stdc++.h>
using namespace std;
struct point{
	int a,i;
	bool operator<(const point&p)const{
		return a<p.a;
	}
}b[2005];
int a[2005];
int k[2005];
bool ok[2005];
int n;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
		b[i].a=a[i];
		b[i].i=i;
	}
	sort(b,b+n);
	for(int i=0;i<n;i++)k[b[i].i]=i;
	int res=0;
	for(int i=0;i<n;i++){
		if(ok[i])continue;
		int j=i;
		int t=0;
		int s=0;
		while(k[j]!=i){
			ok[j]=1;
			s+=a[j];
			j=k[j];
			t++;
		}
//		s+=t*a[j];
		ok[j]=1;
		res+=min(s+t*a[j],s+t*b[0].a+2*(b[0].a+a[j]));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b;
    ll v,w,t;
    cin>>a>>v>>b>>w>>t;
    int flag=0;
    if(a>b) {swap(a,b);}
    if((v-w)*t>=(b-a))flag=1;
    else flag=0;
    if(flag)
    printf("YES\n");
    else
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int s,n;
int main()
{
	cin>>s>>n;
	rep(i,n)
	{
		int k;
		cin>>k;
		s-=k;
	}
	if(s<0) cout<<-1<<endl;
	else cout<<s<<endl;
	return 0;}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 101010;
VL dist(N, UPPER);
void dfs(int x, VE<VE<P<int>>>& G, ll Dist, VE<bool>&visited) { // 実は木上の最短経路はdfsで行ける
	visited[x] = true;
	dist[x] = Dist;
	for (auto c : G[x]) {
		if (!visited[c.first]) {
			dfs(c.first, G, Dist + c.second, visited);
		}
	}
	visited[x] = false;
}
int main() {
	int n;
	cin >> n;
	VE<VE<P<int>>> G(n);
	rep(i, n - 1) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--, b--;
		G[a].push_back(make_pair(b, c));
		G[b].push_back(make_pair(a, c));
	}
	int q, k;
	cin >> q >> k;
	k--;
	dist[k] = 0;
	VE<bool> visited(N, false);
	dfs(k, G, 0, visited);
	while (q--) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--, y--;
		printf("%lld\n", dist[x] + dist[y]);
	}
	return 0;
}

Measured memory_bytes: 17284
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<int> P;
    rep(i, n) {
        int p;
        cin >> p;
        P.push_back(p);
    }
    int ans;
    rep(i, n - 2) {
        int f = P[i];
        int s = P[i + 1];
        int t = P[i + 2];
        if (f < s && s < t) {
            ans++;
        }
        if (t < s && s < f) {
            ans++;
        }
    }
    cout << ans << endl;

}


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

int solve() {
    int n, x; cin >> n >> x;
    int d{0}, l;
    int res = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> l;
        d += l;
        if (d <= x) {
            res++;
        } else {
            break;
        }
    }
    
    return res;
}

int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 3188