akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return f*x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
#define Mod 998244353
struct edge{int v,c,d;};
vector<edge> G[MAXN+5];
inline void Addedge(int u,int v,int c,int d){
	G[u].push_back((edge){v,c,d});
	G[v].push_back((edge){u,c,d});
	return ;
}
int n,fa[MAXN+5][20];
int dep[MAXN+5],dis[MAXN+5][20];
void DFS1(int u){
	dep[u]=dep[fa[u][0]]+1;
	for(int i=0;i<int(G[u].size());i++){
		int v=G[u][i].v;
		if(v==fa[u][0]) continue;
		fa[v][0]=u,dis[v][0]=G[u][i].d;
		DFS1(v);
	}
	return ;
}
void Prepare(){
	for(int j=1;(1<<j)<=n;j++)
		for(int i=1;i<=n;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1],dis[i][j]=dis[i][j-1]+dis[fa[i][j-1]][j-1];
	return ;
}
pair<int,int> LCA(int u,int v){
	if(dep[u]<dep[v]) swap(u,v);
	LL D=dep[u]-dep[v],d=0;
	for(int j=0;(1<<j)<=D;j++)
		if((1<<j)&D)
			d+=dis[u][j],u=fa[u][j];
	if(u==v)
		return make_pair(u,d);
	for(int j=int(log2(n));j>=0;j--)
		if(fa[u][j]!=fa[v][j]){
			d+=dis[u][j],u=fa[u][j];
			d+=dis[v][j],v=fa[v][j];
		}
	return make_pair(fa[u][0],d+dis[u][0]+dis[v][0]);
}
int ans[MAXN+5];
struct node{int id,f,col,d;};
vector<node> Q[MAXN+5];
int cnt1[MAXN+5],cnt2[MAXN+5];
void DFS(int u){//颜色数,颜色长度数
	for(int i=0;i<int(Q[u].size());i++){
		node q=Q[u][i];
		ans[q.id]=ans[q.id]-q.f*cnt2[q.col]+q.f*cnt1[q.col]*q.d;
	}
	for(int i=0;i<int(G[u].size());i++){
		edge e=G[u][i];
		if(e.v==fa[u][0]) continue;
		cnt1[e.c]++,cnt2[e.c]+=e.d;
		DFS(e.v);
		cnt1[e.c]--,cnt2[e.c]-=e.d;
	}
	return ;
}
int main(){
	n=read();int q=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read(),c=read(),d=read();
		Addedge(u,v,c,d);
	}
	DFS1(1);
	Prepare();
	for(int t=1;t<=q;t++){
		int x=read(),y=read(),u=read(),v=read();
		pair<int,int> L=LCA(u,v);
		ans[t]=L.second;
		Q[u].push_back((node){t,1,x,y});
		Q[v].push_back((node){t,1,x,y});
		Q[L.first].push_back((node){t,-2,x,y});
	}
	DFS(1);
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 38644
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n, k, ans = 0; cin >> n >> k;
    vector<int> l(n);
    REP(i, n) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    REP(i, k) ans += l[i];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N = int(input().strip())
A = list(map(int, input().strip().split(" ")))

d = defaultdict(int)

m = -1

for a in A:
    d[a] += 1
    d[a+1] += 1
    d[a-1] += 1
    m = max(d[a], d[a+1], d[a-1], m)

print(m)

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

typedef long long ll;

int main(){
    ll x;
    cin >> x;
    for(ll i = -500; i <= 500; i++){
        for(ll j = -500; j <= 500; j++){
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
ll dp[101][100001];
ll INF = 10000000000;

int main() {
   int N, W;
   cin >> N >> W;
   ll w[N];
   int v[N];
   for (int i = 0; i < N; i++) {
      cin >> w[i] >> v[i];
   }

   dp[0][0] = 0;
   for (int j = 1; j <= N * 1000; j++) dp[0][j] = INF;
   for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= N * 1000; j++) {
         if (j < v[i - 1]) dp[i][j] = dp[i - 1][j];
         else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
      }
   }
   ll ans = 0;
   for (int j = 0; j <= N * 1000; j++) {
      if (dp[N][j] <= W) {
         if (ans < j) ans = j;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 79104
fun main(args: Array<String>) {
    val lines = readLine()!!.split("").filter { it.isNotEmpty() }

    val odd = lines.filterIndexed { index, s -> index % 2 == 0 }
    val even = lines.filterIndexed { index, s -> index % 2 == 1 }

    val odd0 = odd.count { s -> s == "0" }
    val odd1 = odd.size - odd0
    val even0 = even.count { s -> s == "0" }
    val even1 = even.size - even0

    val odd0AndEven1 = odd1 + even0
    val odd1AndEven0 = odd0 + even1

    print(arrayListOf(odd0AndEven1, odd1AndEven0).min())
}

Measured memory_bytes: 46396
import sys
def input():
    return sys.stdin.readline()[:-1]

"""
H Wの後に
#.#.
###.
みたいな文字列を受け取る
"""
H,W = map(int,input().split(' '))
MAP = [['#']*(W+1)] + [None]*H

for i in range(1,H+1):
    MAP[i] = ['#'] + list(map(str,input()))
import queue
q = queue.Queue()


MAP[H][W] = 'G'
visited = [None]*(H+1)
for i in range(H+1):
    visited[i] = [False]*(W+1)

d_num = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if MAP[i][j]=='#':
            d_num += 1

def is_okay(x,y):
    if not (0<x<W+1) or not (0<y<H+1):
        return False
    if visited[y][x] or MAP[y][x]=='#':
        return False
    return True

n = 0
q.put([1,1,n])
ans = 10**7 + 7
delta = [[1,0],[-1,0],[0,1],[0,-1]]
while not q.empty():
    x,y,n = q.get()
    k = MAP[y][x]

    n += 1
    if k=='G':
        ans = min(ans,n)
        break
    for d in delta:
        dx = x+d[0]
        dy = y+d[1]
        if is_okay(dx,dy):
            q.put([dx,dy,n])
            visited[dy][dx] = True

if not ans==10**7 + 7:
    ANS = H*W - ans - d_num
else:
    ANS = -1

print(ANS)

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  for(int i=A; i<=A*B; i+=A){
    if(i%B==C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAX_N 200000

using namespace std;
typedef long long ll;

int par[MAX_N];
int node_rank[MAX_N];
int sizes[MAX_N];

void init(int n){
  for(int i = 0; i < n; i++) {
    par[i] = i;
    node_rank[i] = 0;
    sizes[i] = 1;
  }
}

int find(int x){
  if(par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(node_rank[x] < node_rank[y]){
    par[x] = y;
    sizes[y] += sizes[x];
  }
  else{
    par[y] = x;
    sizes[x] += sizes[y];
  }
  if(node_rank[x] == node_rank[y]) node_rank[x]++;
}

int max_member(int n){
  int maxn = 0;
  for(int i=0; i<n; ++i){
    if(par[i] == i){
      maxn = max(sizes[i], maxn);
    }
  }

  return maxn;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  init(n);
  int a, b;
  for(int i=0; i<m; ++i){
    cin >>a>>b;
    a--; b--;
    unite(a,b);
  }

  int ans = max_member(n);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5512
N = int(input())
li = list(map(int,input().split()))
A = 1
i = 0
B = 0
if 0 in li:
  print(0)
else:
    for i in range (N):
      A = A * li[i]
      if (A > 10**18):
        break
      else: 
        B += 1
        i += 1
    if B == N:
      print (A)
    else:
      print (-1)

Measured memory_bytes: 21704
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
const unsigned int mod = 1e9+7;
const int maxInt = 2147483647;
const int mx=105;
ll n,k;
ll a[200];
ll dp[101][100005];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> k;
    rep(i,n)cin >> a[i];
    dp[0][0]=1;
    rep(i,n){
    	int sum=0;
    	for(int j=0;j<=k;++j){
    		(sum+=dp[i][j])%=mod;
    		dp[i+1][j]=sum;
    		if(j>=a[i]){
    			sum=(mod+sum-dp[i][j-a[i]])%mod;
    		}
    	}
    }
    cout << (dp[n][k])%mod << endl;
    return 0;
}


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

using namespace std;

int main()
{
    set<int>s;
    int n,h,chk=0,c=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>h;
        chk=max(chk,h);

        if(h>=chk)
        {
            c++;
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int sign(ll a){
	return (a>=0)-(a<0);
}
int main(){
	ll K,X,Y;
	vll ans[2];
	scan(K>>X>>Y);
	ll x=max(abs(X),abs(Y)),y=min(abs(X),abs(Y));
	if(K%2==0&&(x+y)%2==1){
		prin(-1);
		return 0;
	}
	ll n;
	if(x+y<K){
		if((x+y)%2==0){
			n=2;
		}
		else{
			n=3;
		}
	}
	else{
		ll c=(K-(x+y)%K)%K;//無駄に歩かないといけない距離
		if(c%2==0){
			n=(x+y)/K+((x+y)%K!=0);
			//sub_25はこのケース
		}
		else{
			n=(x+y)/K+((x+y)%K!=0)+1;
		}
	}
	ll nowx=0,nowy=0;
	if(n==1){
		ans[0].push_back(x),ans[1].push_back(y);
	}
	else if(x+y<K&&(x+y)%2==1){//タイプB
		nowy-=K-x;
		nowx+=x;
		ans[0].push_back(nowx),ans[1].push_back(nowy);
		nowx+=(K+x-y)/2;
		nowy+=K-(K+x-y)/2;
		ans[0].push_back(nowx),ans[1].push_back(nowy);
		nowx=x,nowy=y;
		ans[0].push_back(nowx),ans[1].push_back(nowy);
	}
	else{//タイプA
		int flag=0;
		ll sita=-(K*n-x-y)/2;
		rep(i,n){
			ll oldx=nowx,oldy=nowy;
			if(flag==0){
				if(nowy-K>sita) nowy-=K;
				else{
					nowx+=K-(nowy-sita);
					nowy=sita;
				}
				if(nowy==sita) flag=1;
			}
			else if(flag==1){
				if(nowx+K<x){
					nowx+=K;
				}
				else{
					nowy+=K-(x-nowx);
					nowx=x;
				}
				if(nowx==x) flag=2;
			}
			else{
				nowy+=K;
			}
			ans[0].push_back(nowx),ans[1].push_back(nowy);
		}
	}
	prin(n);
	rep(i,n){
		if(abs(X)>=abs(Y)) printf("%lld %lld\n",sign(X)*ans[0][i],sign(Y)*ans[1][i]);
		else printf("%lld %lld\n",sign(X)*ans[1][i],sign(Y)*ans[0][i]);
	}
	return 0;
}


Measured memory_bytes: 5604
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(m)]

place = [0] * len(AB)
for i, ab in enumerate(AB):
    dist = 10 ** 9
    for j, cd in enumerate(CD):
        tmp = abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])
        if tmp < dist:
            dist = tmp
            place[i] = j + 1
            
for i in place:
    print(i)

Measured memory_bytes: 3064
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	printf(N <= K ? "unsafe" : "safe");
	return 0;
}

Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        char c = s[0];

        string answer = "";
        if(c >= 'a')
        {
            answer = "a";
        } else
        {
            answer = "A";
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> tail,face;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    rep(i,N){
        if(i%2==0){
            tail.pb(A[i]);
        }
        else face.pb(A[i]);
    }
    
    if(N%2==0){
        rrep(i,sz(face)) cout<<face[i]<<" ";
        rep(i,sz(tail)) cout<<tail[i]<<" ";
    }
    else{
        rrep(i,sz(tail)) cout<<tail[i]<<" ";
        rep(i,sz(face)) cout<<face[i]<<" ";
    }
}


Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
//素数判定
bool is_prime(long long n){
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
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; }

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    rep(i,n){
        cin >> A[i];
        B[i]=A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    int Max = A[0];
    int sMax;
    if (A[1] == Max)
    {
        sMax = Max;
    }else{
        sMax = A[1];
    }
    //cout << Max << sMax << endl;
    rep(i, n)
    {
        if(B[i]==Max){
            cout << sMax << endl;
        }else{
            cout << Max << endl;
        }
    }

        return 0;
}

Measured memory_bytes: 4824
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

class event {
   public:
    int kind;  // 0: end, 1: begin
    int time;
    int chan;

    event() : kind(0), time(0), chan(0) {}
    event(int kind, int time, int chan) : kind(kind), time(time), chan(chan) {}

    bool operator<(const event& e) const { return time < e.time; }
};

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

    vector<event> events;

    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;

        events.push_back(event(1, 2 * s - 1, c - 1));
        events.push_back(event(0, 2 * t, c - 1));
    }

    sort(events.begin(), events.end());

    int rec_cnt = 0;
    int on_recoder_num = 0;
    int off_recoder_num = 0;

    vector<int> recoding(c);
    for (const event& e : events) {
        if (e.kind == 0) {  // end
            recoding[e.chan]--;
            if (recoding[e.chan] == 0) {
                on_recoder_num--;
                off_recoder_num++;
            }
        } else {  // begin
            if (recoding[e.chan] > 0) {
                recoding[e.chan]++;
                continue;
            }
            if (off_recoder_num == 0) {
                rec_cnt++;
                off_recoder_num++;
            }

            off_recoder_num--;
            on_recoder_num++;
            recoding[e.chan] = 1;
        }
    }

    cout << rec_cnt << endl;

    return 0;
}


Measured memory_bytes: 4980
#include <stdio.h>
#define MAX(x,y)	((x)>(y)?(x):(y))
int main(){
  int k,n,max=0,a[200000+1]={0};
  scanf("%d%d",&k,&n);
  for(int i=0; i<n; i++){
    scanf("%d",&a[i]);
    if(i){ max = MAX( max, (a[i] - a[i-1]) ); }
  }
  max = MAX( max, (k-a[n-1]+a[0]) );
  printf("%d", k-max);
  return 0;
}

Measured memory_bytes: 2488
import java.util.*;
//累積はプログラミングの世界での呼ばれ方
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N = s.nextInt();
    int Q = s.nextInt();
    String S = s.next();
    int[] l1 = new int[Q] , r1 = new int[Q] , SR = new int[N];
    for(int i = 0; i < Q; i++){
      //System.out.println(N + " " + Q + " " + S);
      l1[i] = s.nextInt();
      r1[i] = s.nextInt();
    }

    SR[0] = 0;
    for(int i = 1; i < N; i++){
      if(S.charAt(i - 1) == 'A' && S.charAt(i) == 'C'){
        SR[i] = SR[i - 1] + 1;
      }
      else{
        SR[i] = SR[i - 1];
      }
    }
    /*
    for(int i = 0; i < N; i++) {
      System.out.print(SR[i]);
    }
    */
    //System.out.println("");
    for(int i = 0; i < Q; i++){
      System.out.println(SR[r1[i] - 1] - SR[l1[i] - 1]);
    }
  }
}


Measured memory_bytes: 82572
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

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

int main(){
    string a, b;
    cin >> a >> b;
    string ans = "";
    int anum = stoi(a);
    int bnum = stoi(b);

    if (a <= b){
        rep(i, bnum) ans += a;
    }else{
        rep(i, anum) ans += b;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import math

n,d = map(int,input().split())
a_list = []
for i in range(n):
  t = list(map(int,input().split()))
  a_list.append(t)

ans = 0
for i in range(n):
  ai = a_list[i]
  for j in range(i+1,n):
    aj = a_list[j]
    l = math.sqrt(sum([(x-y)**2 for (x,y) in zip(ai, aj)]))
    if l - round(l) == 0:
      ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl d = vv(n, 2, 0, ll);
  re(i, n) std::cin >> d[i][0] >> d[i][1];
  sort(all(d));
  multiset<ll, greater<ll>> s;
  ll ans = 0;
  for(int i=1, j=0;i<=m;i++){
    while(j<n&&d[j][0]==i) s.insert(d[j][1]), j++;
    if(s.size()==0) continue;
    ans += (*s.begin()), s.erase(s.begin());
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 10368
import java.util.*;

class Main {

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

    static int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }

    public static void main(String[] args) {

        long res = 0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        char[] ch = str.toCharArray();

        long r = 0;
        long g = 0;
        long b = 0;
        for (int i = 0; i < n; i++) {
            if (ch[i] == 'R') {
                r++;
            } else if (ch[i] == 'G') {
                g++;
            } else {
                b++;
            }
        }
        res = r * g * b;

        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; 2 * j - i < n; j++) {
                if (ch[i] != ch[j] && ch[j] != ch[j * 2 - i] && ch[j * 2 - i] != ch[i]) {
                    res--;
                }
            }
        }

        System.out.println(res);
        sc.close();
    }
}


Measured memory_bytes: 36568
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  set<char> q(s.begin(), s.end());
  for (auto x : t) {
    if (!q.count(x)) {
      cout << -1 << endl;
      return 0;
    }
  }
  const int n = s.size();
  s += s;
  vector<array<int, 26>> d(s.size());
  array<int, 26> a;
  for (int i = 0; i < 26; ++i) a[i] = s.size();
  for (int i = int(s.size()) - 1; i >= 0; --i) {
    a[s[i] - 'a'] = i;
    d[i] = a;
  }
  int64_t ans = 0;
  int pos = 0;
  for (char c : t) {
    int idx = c - 'a';
    pos = d[pos][idx] + 1;
    if (pos >= n) pos -= n, ans += n;
  }
  cout << ans + pos << endl;


  return 0;
}



Measured memory_bytes: 20972
#include<stdio.h>
#define MAX_V 1000000
int prime[MAX_V + 1];
int sum[MAX_V + 1];
int main(){
  int n, i, k;
  prime[0]=prime[1]=0;
  for(i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(i=2;i*i<=MAX_V;i++){
    if(prime[i]){
      for(k = 2*i;k <= MAX_V;k += i){
        prime[k] = 0;
      }
    }
  }
  sum[0] = 0;
  for(i = 0;i < MAX_V;i++){
    sum[i+1] = sum[i]+prime[i+1];
  }
  while(scanf("%d", &n) == 1){
    printf("%d\n", sum[n]);
  }
  return 0;
}

Measured memory_bytes: 9560
#include <stdio.h>
int arr[4];
int main(){
	for(int i=0;i<4;i++) scanf("%1d",arr+i);
	int a=arr[0]*10+arr[1], b=arr[2]*10+arr[3];
	int s=0;
	if(a<=12&&a>0) s++;
	if(b<=12&&b>0) s+=2;
	if(s==0) printf("NA");
	else if(s==3) printf("AMBIGUOUS");
	else if(s==1) printf("MMYY");
	else printf("YYMM");
}

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


int main() {
    long long a,b,k;
    cin>>a>>b>>k;
    
    b = max( b- max(k-a, 0LL), 0LL);
    a = max(a-k, 0LL);
    cout << a <<" "<<b << endl;
    return 0;
}

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

class Dice{
	public:
		int one;
		int two;
		int three;
		int four;
		int five;
		int six;
	
	void korokoro(char muki);
};

void Dice::korokoro(char muki){
	int tmpone=one;
	int tmptwo=two;
	int tmpthree=three;
	int tmpfour=four;
	int tmpfive=five;
	int tmpsix=six;
	if(muki=='N'){
		one=tmptwo;
		two=tmpsix;
		five=tmpone;
		six=tmpfive;
	}
	if(muki=='S'){
		one=tmpfive;
		two=tmpone;
		five=tmpsix;
		six=tmptwo;
	}
	if(muki=='W'){
		one=tmpthree;
		three=tmpsix;
		four=tmpone;
		six=tmpfour;
	}
	if(muki=='E'){
		one=tmpfour;
		three=tmpone;
		four=tmpsix;
		six=tmpthree;
	}
}

int main(){
	Dice dice;
	cin>>dice.one>>dice.two>>dice.three>>dice.four>>dice.five>>dice.six;
	string S;
	cin>>S;
	for(int i=0;i<S.length();++i){
		dice.korokoro(S[i]);
	}
	cout<<dice.one<<endl;
}


Measured memory_bytes: 3168
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    c=x%y
    return gcd(y,c)   
def lcm( x, y):
    return (x*y)//gcd(x,y)
a,b,c,d=map(int,input().split())
C =b//c-(-(-a//c))
D= b//d-(-(-a//d))
EX=  lcm(c,d)
EX=b//EX+(-a//EX)
print(b-a-(C+D)+EX)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])cout << "Yes";
    else cout << "No";
}      

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n, m, a, b;
	scanf("%d%d%d%d", &n, &m, &a, &b);
	REP(i, 0, n) {
		REP(j, 0, m) {
			if (i < b && j < a || i >= b && j >= a) {
				putchar('0');
			} else {
				putchar('1');
			}
			
		}
		putchar('\n');
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    int cnt=0;

    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];

    for(int i=0;i<n;i++)
    {
        if(a[i] - b[i] > 0)
            cnt+=a[i]-b[i];
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
int main(){
int n,c=0;
cin>>n;
int a[n];
if(n<3)
    cout<<0;
else
{
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<n-2;i++)
{
    for(int j=i+1;j<n-1;j++)
    {
        for(int k=j+1;k<n;k++)
        {
            if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])
                c++;
        }
    }
}
cout<<c;
}
}









Measured memory_bytes: 3460
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
#include <set>
#include<iomanip>
using namespace std;


int main(){
    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    double answer = 0.0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            answer += sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2));
        }
    }
    printf("%.10f\n", answer * 2 / n);
    // ans * 2 * (n - 1)! / n!
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
count = 0
roop = True

while roop == True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] /= 2
        else:
            roop = False
            break
    if roop == True:
        count += 1
print(count)

Measured memory_bytes: 9024
#include<stdio.h>

int main(void)
{
   int h, n, a[100000], s=0, i;

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

   if(h<=s)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	a=x-a;
	b=x-b;
	if(a<0) a*=-1;
	if(b<0) b*=-1;
	if(a<=b) printf("A\n");
	else printf("B\n");
	return 0;
}


Measured memory_bytes: 1656
#include "bits/stdc++.h"
using namespace std;

const int N = 200005;
bitset< N> ok;
bitset< 10> chk;



int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b) swap(a, b);
    if(a < c) swap(a, c);
    cout << a * 10 + b + c << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}
int main(){
	ll n;
	cin>>n;
	ll a[n],ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = ReadInt();
            var a = ReadInt();
            var b = ReadInt();
            var c = ReadInt();
            var d = ReadInt();

            var kokugo = a / c;
            if (a % c != 0) kokugo++;

            var sansuu = b / d;
            if (b % d != 0) sansuu++;

            WriteLine(l - Max(kokugo,sansuu));
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15908
#define _GLIBCXX_DEBUG //compiles STL in debug mode
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <limits>

using namespace std;

#define ALL(c) (c).begin(), (c).end()
#define ASC_SORT(c) sort(ALL(c))
#define DESC_SORT(c) sort(ALL(c), greater<int>())
#define MAX3(a,b,c) max(max((a),(b)),(c))
#define MIN3(a,b,c) min(min((a),(b)),(c))
#define MAXN(t) numeric_limits<t>::max()
#define MINN(t) numeric_limits<t>::min()

using ll = long long;
using ull = unsigned long long;
template<typename T> class p : pair<T, T> {
  T &x = pair<T, T>::first, &y = pair<T, T>::first;
};
//template<typename T> using p = pair<T, T>;
using ld = long double;
using pld = p<ld>;
template<typename T> using v = vector<T>;
using vpld = v<pld>;

constexpr ld EPS {1e-11};
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
int sgn(const ld& a, const ld& b) { return sgn(a - b); }
bool eq(const ld& a, const ld& b) { return sgn(a, b) == 0; }

//TODO: implement MAXN, MINN as constexpr
//calc sums via accumulate

template<typename T> void rep(T init, T n, function<void(T)> f) {
  for(T i {init}; i < n; i++) f(i);
}
ll operator*(ll n, function<void(void)> f) {
  for(ll i {0}; i < n; i++) f();
  return 0;
}

template<typename C, typename D>
D fmap(function<typename D::value_type(typename C::value_type)> f, C c) {
  D ret;
  transform(c.begin(), c.end(), back_inserter(ret), f);
  return ret;
}

template<typename C>
C ffilter(function<bool(typename C::value_type)> f, C c) {
  C ret;
  remove_copy_if(c.begin(), c.end(), back_inserter(ret),
    [&f](typename C::value_type e){ return !f(e); });
  return ret;
}

template<typename C, typename T>
T ffold(function<T(T, typename C::value_type)> f, T init, C c) {
  return accumulate(c.begin(), c.end(), init, f);
}
template<typename C>
typename C::value_type ffold(function<typename C::value_type(typename C::value_type, typename C::value_type)> f, C c) {
  return accumulate(c.begin()+1, c.end(), *c.begin(), f);
}

template<typename C>
C frange(typename C::value_type begin, typename C::value_type end) {
  C ret;
  for(auto i = begin; i != end; i++) ret.push_back(i);
  return ret;
}

int main()
{
  ios::sync_with_stdio(false); //USE "\n" INSTEAD OF endl. Do NOT use printf.
  cin.tie(0);
  int n;
  cin >> n;
  v<int> L(n*2);
  rep<int>(0, 2*n, [&](int i) { cin >> L[i]; });
  sort(L.begin(), L.end());
  int ans {0};
  rep<int>(0, n, [&](int i) {
    //cout << i*2 << ": " << L[i*2] << endl;
    ans += L[i*2];
  });
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const mod = 10^^9 + 7;

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(long n, long k, long mod) {
    long x = 1;
    for (int i = 0; i < k; i++) {
        x = (x * (n - i)) % mod;
    }
    long kk = iota(1, k+1).reduce!((a, b) => a * b % mod);
    return (x * modPow(kk, mod - 2, mod)) % mod;
}

long calc(long n, long a, long b) {
    long ans = modPow(2, n, mod);
    ans = (ans - nck(n, a, mod) + mod) % mod;
    ans = (ans - nck(n, b, mod) + mod) % mod;
    ans--;
    return ans;
}

void main() {
    int n, a, b; scan(n, a, b);
    writeln(calc(n, a, b));
}


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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string a,b,c;cin>>a>>b>>c;
  string ans="aaa";
  ans[0]=a[0]+'A'-'a';
  ans[1]=b[0]+'A'-'a';
  ans[2]=c[0]+'A'-'a';
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,x,flag=0,count=0,n,k;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<'\n';
  return(0);
}


Measured memory_bytes: 256
n,qtm = map(int, input().split())

class Process:
  def __init__(self, name, time):
    self.name = name
    self.time = time

class Queue:
  def __init__(self, length):
    self.q = [Process('p0', 0)]*length
    self.MAX = length
    self.head = 0
    self.tail = 0
  
  def enqueue(self, x):
    self.q[self.tail] = x
    if self.tail+1 == self.MAX:
      self.tail = 0
    else:
      self.tail += 1 
  
  def dequeue(self):
    x = self.q[self.head]
    if self.head + 1 == self.MAX:
      self.head = 0
    else: 
      self.head += 1
    return x
  
  def isEmpty(self):
    if self.head == self.tail:
      return True
    else:
      return False

  def isFull(self):
    if self.head == (self.tail+1)%self.MAX:
      return True
    else:
      False


Q = Queue(100000) 

for _ in range(n):
  x,y = map(str, input().split())
  tmp = Q.enqueue(Process(x,int(y)))

time = 0
while not Q.isEmpty():
  qtop = Q.dequeue()
  if qtop.time > qtm:
    time += qtm
    qtop.time -= qtm
    Q.enqueue(qtop) 
  else:
    time += qtop.time
    qtop.time = 0
    print(qtop.name + ' ' + str(time))




Measured memory_bytes: 17664
/*
	RAone00
	Rohit sharma
	*/

	#include <bits/stdc++.h>
	using namespace std;

	typedef long long ll;
	typedef long double ld;
	typedef pair < ll, ll > pll;
	typedef vector < vector < ll > > matrix;
	typedef vector < ll > vll;

	#define pb push_back
	#define debug(x) cout << (#x) << " is " << (x) << endl
	#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

	const ll mod = 1e9 + 7;
	const ll inf = LLONG_MAX;
	const ll N = 1e5 + 10;

	
	int main() {
	    fast_io();
	    string a;
	    cin >> a;
	    int c = 0;
	    for (int i = 0; i < a.size(); ++i) {
	    	if (a[i] == '7') c++;
	    }
	    if (c >= 1) cout << "Yes\n";
	    else cout << "No\n";
	    return 0;
	}

 	

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <numeric>
#include <limits>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
const int V = 10;
struct edge { int to, cost; };
std::vector<edge>v[100];
typedef std::pair<int, int>p;

int main() {
	int n, s[100000], q, t[100000], ans = 0;
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> s[i];
	}
	std::sort(s, s + n);
	std::cin >> q;
	for (int i = 0;i < q;i++) {
		std::cin >> t[i];
	}
	for (int i = 0;i < q;i++) {
		int left = -1, right = n, k = t[i];
		while (right - left > 1) {
			int mid = (left + right) / 2;
			if (s[mid] >= k) {
				right = mid;
			}
			else {
				left = mid;
			}
		}
		if (s[right] == k) {
			ans += 1;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3676
require 'matrix'
N, M = gets.split.map &:to_i
a = []
N.times{|i|
  a[i] = gets.split.map(&:to_i)
}
b = []
M.times{b <<  gets.to_i}
A = Matrix[*a]
B = Vector[*b]
puts (A * B).to_a

Measured memory_bytes: 9344
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
Node = Struct.new(:parent, :left, :right)

nodes = Array.new(N) { Node.new }

def get_depth(id, nodes)
  d = 0
  while ! nodes[id].parent.nil? do
    id = nodes[id].parent
    d += 1
  end
  d
end

def get_children(id, nodes)
  children = []
  c = nodes[id].left
  while not c.nil?
    children << c
    c = nodes[c].right
  end
  children
end

for i in 1...(array.size)

  carray = array[i].split(" ")
  id = carray[0].to_i
  k  = carray[1].to_i
  c  = carray.slice(2, carray.length+1).map(&:to_i)

  # set parents for each children
  c.each do |child|
    nodes[child].parent = id
  end

  # set left node for this node
  nodes[id].left = c.first

  # set left/right nodes
  c.inject do |l, r|
    nodes[l].right = r
  end
end

nodes.each_with_index do |node, index|

  children = get_children(index, nodes)

  type = if node.parent.nil?
           "root"
         elsif children.empty?
           "leaf"
         else
           "internal node"
         end

  puts "node #{index}: parent = #{node.parent.nil? ? -1 : node.parent}, depth = #{get_depth(index, nodes)}, #{type}, #{children.to_s}"
end

Measured memory_bytes: 26204
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	p = 998244353
	n,s = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	dp = zeros(Int,n,s)
	if a[1]<=s
		dp[1,a[1]] = 1
	end
	ans = dp[1,s]*n
	for i in 2:n
		if a[i]<=s
			dp[i,a[i]] += i
		end
		for j in 1:s
			if j!=s
				dp[i,j]=(dp[i,j]+dp[i-1,j])%p
			end
			if j+a[i]<=s
				dp[i,j+a[i]]=(dp[i,j+a[i]]+dp[i-1,j])%p
			end
		end
		ans = (ans+(dp[i,s]%p)*(n+1-i)%p)%p
	end
	println(ans)
end

main()

Measured memory_bytes: 183164
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    
    n=n%10;
    switch (n) {
        case 3:
            cout << "bon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        default:
            break;
    }
    
    return 0;
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				double d = Double.parseDouble(buf);
				if (d<=48.00) System.out.println("light fly");
				else if (d<=51.00) System.out.println("fly");
				else if (d<=54.00) System.out.println("bantam");
				else if (d<=57.00) System.out.println("feather");
				else if (d<=60.00) System.out.println("light");
				else if (d<=64.00) System.out.println("light welter");
				else if (d<=69.00) System.out.println("welter");
				else if (d<=75.00) System.out.println("light middle");
				else if (d<=81.00) System.out.println("middle");
				else if (d<=91.00) System.out.println("light heavy");
				else System.out.println("heavy");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16900
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

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

const int inf = 1 << 28;

int a_init, b_init, n;
Vi vc;
// dp[acting player][the number of cards remaining when a turn is passed]
int dp[2][2001];

void init()
{
	cin >> n >> a_init >> b_init;

	vc.resize(n);
	REP(i, n) cin >> vc[i];
}

int main()
{
	init();

	dp[1][n] = abs(b_init - vc.back());

	for (int i = 1; i < n; ++i)
	{
		int c_other = vc[n - i - 1];
		int res;

		// p0, maximize
		res = abs(vc.back() - c_other);
		for (int j = i - 1; j >= 1; --j)
			chmax(res, dp[1][j]);

		dp[0][i] = res;

		// p1, minimize
		res = abs(vc.back() - c_other);
		for (int j = i - 1; j >= 1; --j)
			chmin(res, dp[0][j]);
		dp[1][i] = res;
	}

	int ans = abs(b_init - vc.back());
	for (int i = n - 1; i >= 1; --i)
		chmax(ans, dp[1][i]);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    string s,t; cin>>s>>t;
    bool flag = false;
    for(int i=0;i<s.size();i++){
        if(s==t){
            flag = true;
            break;
        }
        //末尾を先頭に持ってきて回転させる
        //0からsizeよりも一つ少なく切り出す
        s = s.back()+s.substr(0,s.size()-1);
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  char a;
  cin >>a;
  if(a=='A'){
    cout <<'T' <<endl;
  }
  else if(a=='T'){
    cout <<'A' <<endl;
  }
  else if(a=='C'){
    cout <<'G' <<endl;
  }
  else{
    cout <<'C' <<endl;
  }
  return 0;
}

Measured memory_bytes: 256