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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> cnt(N, 0);
    REP(i, Q){
    	ll A;
    	cin >> A;
    	A--;
    	cnt[A]++;
    }
    REP(i, N){
    	cout << (K-(Q-cnt[i])>0 ? "Yes" : "No") << endl;
    }
    return 0;
}

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

int main(){
	int M, D, m, d, ans = 0;
	scanf("%d%d", &M, &D);
	for(m = 1; m <= M; m++){
		for(d = 1; d <= D; d++){
			int d1 = d % 10;
			int d10 = d / 10;
			if(d1 >= 2 && d10 >= 2 && d1 * d10 == m){
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

inline void Main() {
  // code
  string s;
  cin >> s;
  int r = 0;

  rep(i, s.length()) {
    repi(j, i, s.length()) {
      bool check = true;
      repi(k, i, j+1) {
        if (
          s.at(k) == 'A' ||
          s.at(k) == 'C' ||
          s.at(k) == 'G' ||
          s.at(k) == 'T'
        ) {} else {
          check = false;
        }
      }
      if(check) {
        r = max(r, j-i+1);
      }
    }
  }
  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    H=[0]+list(map(int,input().split()))

    dp=[[INF]*(n-k+1) for _ in range(n+1)]
    dp[0][0]=0

    for x in range(1,n+1):
        for y in range(1,n-k+1):
            dp[x][y]=min(dp[x0][y-1]+max(0,H[x]-H[x0]) for x0 in range(x))

    print(min(*(dp[x][n-k] for x in range(n+1))))
resolve()

Measured memory_bytes: 48092
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    int n;
    cin >> n;
    int minn = INF;
    int minid = 0;
    int maxn = -INF;
    int maxid = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(minn>a[i]){
            minn = a[i];
            minid = i;
        }
        if(maxn<a[i]){
            maxn = a[i];
            maxid = i;
        }
    }
    if(abs(maxn) >=abs(minn)){
        vector<pair<int, int>> vp(n);
        for (int i = 0; i < n; i++)
        {
            vp[i] = {maxid, i};
            a[i] += a[maxid];
        }
        int c = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if(a[i]>a[i+1]){
                vp.push_back({i, i + 1});
                a[i + 1] += a[i];
            }
        }
      //  show(vp);
        assert(vp.size() <= 2 * n);
        cout << vp.size() << endl;
        for (int i = 0; i < vp.size(); i++)
        {
            cout << vp[i].first +1<<" "<< vp[i].second+1 << endl;
            
        }

        }
    else{
        vector<pair<int, int>> vp(n);
        for (int i = 0; i < n; i++)
        {
            vp[i] = {minid, i};
            a[i] += a[minid];
        }

        int c = 0;
        for (int i = n-1; i >=1; i--)
        {
            if (a[i] < a[i - 1])
            {
                vp.push_back({i, i-1});
                a[i-1] += a[i];
            }
            
        }
        for (int i = 0; i < n-1; i++)
        {
            assert(a[i] <= a[i + 1]);
        }
        

       // assert(vp.size() <= 2 * n);
        cout << vp.size() << endl;
        for (int i = 0; i < vp.size(); i++)
        {
            cout << vp[i].first +1<<" "<< vp[i].second +1<< endl;
        }
    }

    return 0;
}

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

int main()
{
  	string date;
  	cin>>date;
  	int year,month,day;
  	istringstream iss(date);
    getline(iss,date,'/');
    year=stoi(date);
    getline(iss,date,'/');
    month=stoi(date);
    getline(iss,date,'/');
    day=stoi(date);
  	if(year<=2019 && month<=4 && day<=30)
    cout<<"Heisei";
    else
    cout<<"TBD";
    cout<<endl;
	return 0;
}

Measured memory_bytes: 256
from math import gcd
mod = 1000000007
n = int(input())
zero = 0
bad = {} # 仲が悪い者同士をグループ化
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zero += 1 # (A,B) = (0,0) の計数をとる
        continue
    g = gcd(x, y)
    x //= g # ベクトルを整数の範囲で最小化し、
    y //= g # 傾きを既約分数 (y'/x') の形にする
    # ベクトルを0≦θ＜πの範囲に変換する
    if y < 0: x, y = -x, -y # 第3~4象限のベクトルはπ回転
    if y==0 and x<0: x, y = -x, -y # θ=πのベクトルはθ=0へ
    # π/2≦θ＜πは、π/2回転して同じキーにする
    is_rotate90 = (x <= 0)
    if is_rotate90: x, y = y, -x # π/2回転
    if not (x, y) in bad: bad[x, y] = [0, 0]
    # π/2回転したもの、してないものは別に計数をとる
    bad[x, y][is_rotate90] += 1

ans = 1 # 組み合わせを掛けていくので 1 から
for x, y in bad:
    c1, c2 = bad[x, y]
    # c1, c2 両方選択は仲が悪いのでできない
    # c1 の側のみを 1 個以上選択する
    # c2 の側のみを 1 個以上選択する
    # c1, c2 どちらも選択しない
    c3 = (pow(2, c1, mod) - 1) + (pow(2, c2, mod) - 1) + 1
    ans *= c3
    ans %= mod

# (A,B)=(0,0)は、単独でしか選択できないので、+zero する
# 全て未選択はできないので、-1 する
ans += zero - 1
ans = (ans + mod) % mod # 負数対応
print(ans)


Measured memory_bytes: 60296
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll x, y;
    std::cin >> x >> y;
    if(x > y) std::swap(x, y);
    ll cnt = 0;
    ll val = x;
    while(val <= y){
        cnt++;
        val += val;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main () {
  int n , k ;
  cin >> n >> k ;
  vector<bool> v(n+1 , 0) ;
  for (int i = 0 ; i < k ; ++i) {
    int a ;
    cin >> a ;
    for (int j = 0 ; j < a ; ++j) {
      int b ;
      cin >> b ;
      v[b] = 1 ;
    }
  }
  int cnt = 0 ;
  for (int i = 1 ; i <= n ; ++i) {
    if (v[i] == 0) {
      ++cnt ;
    }
  }
  cout << cnt ;
  return 0 ;
}

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

// UnionFind
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }
  rep(i, k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i, n) {
    int ans = uf.size(i)-1-deg[i];
    for (int u : to[i]){
      if (uf.same(i, u)) --ans;
    }
    printf("%d%c", ans, i==n-1?'\n':' ');
  }

  return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


using namespace std;


int main(){
    double ans=0.0;
    int n;
    cin>>n;
    for(int i = 0; i < n; i++){
        double temp;
        cin>>temp;
        ans+=temp;
    }
    ans/=n;
    cout<<(int)ans<<endl;
}

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

int main(void){
    int N,K;
    cin>>N>>K;
    vector<int> l(N);
    rep(i,N)cin>>l[i];
    sort(all(l));
    int sum=0;
    rep(i,K){
        sum+=l[N-i-1];
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
r = [(input().split()) for _ in range(n)]
r = [(float(i),float(j)) for (i,j) in r]
total = 0
for i, (x,y) in enumerate(r):
    for a,b in r[i+1:]:
        length = math.sqrt((x-a)**2 + (y-b)**2)
        total += length
print(2*total/n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A; cin >> A;
  int f = A/100;
  int b = A%100;
  if((f > 12) || (f == 0)){
      if((0 < b) && (b < 13)){
          printf("YYMM");
      }else{
          printf("NA");
      }
  }else{
      if((0 < b) && (b < 13)){
          printf("AMBIGUOUS");
      }else{
            printf("MMYY");
      }
    }
}

Measured memory_bytes: 256
from sys import stdin
A,B,M = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
b = [int(x) for x in stdin.readline().rstrip().split()]
ans = min(a)+min(b)

for i in range(M):
    x,y,c = [int(x) for x in stdin.readline().rstrip().split()]
    if ans >= a[x-1] + b[y-1] - c:
        ans = a[x-1] + b[y-1] - c

print(ans)

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

int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D;
  
  if ( A + B == C + D ) {
    cout << "Balanced" << endl;   
  }
  else if ( A + B >  C + D ) {
      cout << "Left" << endl;
  }
    else {
      cout << "Right" << endl;
  }
    
}

Measured memory_bytes: 256
#!usr/bin/perl

use strict;

my ($n,$k) = split/ /,<>;
my $last_value = $n;

my $remain = $n % $k;

my $min;

if ($remain == 0) {
  $min = 0;
} else {
  my $diff = $remain - $k;
  if ($diff < 0) {
    $diff *= -1;
  }
  if ($remain > $diff) {
    $remain = $diff;
  }
  $min = $remain;
}
print "$min \n";

Measured memory_bytes: 512
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()
	inputList := strings.Split(input, " ")
	n, _ := strconv.Atoi(inputList[0])

	fmt.Println((n - 1) / 2)
}


Measured memory_bytes: 640
#include<stdio.h>
  
int main(void){
    int i,n[6],q,a,b;
      
    for(i=0;i<6;i++){
        scanf("%d", &n[i]);
    }
      
    scanf("%d",&q);
    for(i=0; i<q; i++){
    scanf("%d %d",&a,&b);
    if(a == n[0]){
       if(b == n[1]){
          printf("%d\n",n[2]);
       }
       if(b == n[2]){
          printf("%d\n",n[4]);
       }
       if(b == n[3]){
          printf("%d\n",n[1]);
       }
       if(b == n[4]){
          printf("%d\n",n[3]);
       }
    }
    if(a == n[1]){
       if(b == n[0]){
          printf("%d\n",n[3]);
       }
       if(b == n[2]){
          printf("%d\n",n[0]);
       }
       if(b == n[3]){
          printf("%d\n",n[5]);
       }
       if(b == n[5]){
          printf("%d\n",n[2]);
       }
    }
    if(a == n[2]){
       if(b == n[0]){
          printf("%d\n",n[1]);
       }
       if(b == n[1]){
          printf("%d\n",n[5]);
       }
       if(b == n[4]){
          printf("%d\n",n[0]);
       }
       if(b == n[5]){
          printf("%d\n",n[4]);
       }
    }
    if(a == n[3]){
       if(b == n[0]){
          printf("%d\n",n[4]);
       }
       if(b == n[1]){
          printf("%d\n",n[0]);
       }
       if(b == n[4]){
          printf("%d\n",n[5]);
       }
       if(b == n[5]){
          printf("%d\n",n[1]);
       }
    }
    if(a == n[4]){
       if(b == n[0]){
          printf("%d\n",n[2]);
       }
       if(b == n[2]){
          printf("%d\n",n[5]);
       }
       if(b == n[3]){
          printf("%d\n",n[0]);
       }
       if(b == n[5]){
          printf("%d\n",n[3]);
       }
    }
    if(a == n[5]){
       if(b == n[1]){
          printf("%d\n",n[3]);
       }
       if(b == n[2]){
          printf("%d\n",n[1]);
       }
       if(b == n[3]){
          printf("%d\n",n[4]);
       }
       if(b == n[4]){
          printf("%d\n",n[2]);
       }
    }
}
    return 0;
}


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

int main(){
  int n,K;
  cin >> n >> K;
  vector<long> v(n);
  long result = -100000000000000000;
  for(int i = 0;i < n;i++){
    cin >> v.at(i);
  }
  for(int i = 0;i <= min(n,K);i++){
    for(int j = 0;j <= i;j++){
      long sum = 0;
      vector<long> a;
      for(int k = 0;k < j;k++){
        sum += v.at(k);
        a.push_back(v.at(k));
      }
      for(int k = n-i+j;k < n;k++){
        sum += v.at(k);
        a.push_back(v.at(k));
      }
      sort(a.begin(),a.end());
      for(int k = 0;k < min(K-i,i);k++){
        if(j != 0){
          if(a.at(k) >= 0){
            break;
          }
          sum -= a.at(k);
        }
      }
      result = max(result,sum);
      //cout << result << endl;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll s[2005][2005], ans[2005*2005]={0};
  ll n,x,y;
  cin>>n>>x>>y; 
  ll a=x, b=y;
  x = min(a,b);
  y = max(a,b);
  for(ll i=1;i<=n;i++)
    for(ll j=i+1;j<=n;j++)
        s[i][j] = min(j-i, abs(x-i)+abs(y-j)+1);
   for(ll i=1;i<=n;i++)
    for(ll j=i+1;j<=n;j++)
       ans[s[i][j]]++;
    for(int i=1;i<n;i++)
     cout<<ans[i]<<"\n"; 
  return 0;
}

Measured memory_bytes: 63104
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <math.h>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;

int main() {

   ll N, D;
   scanf("%lld %lld", &N, &D);

   int ans = 0;
   for (int i = 0; i < N; i++) {
      ll X, Y;
      scanf("%lld %lld", &X, &Y);
      if (X * X + Y * Y <= D * D) {
         ans++;
      }
   }
   printf("%d\n", ans);

   return 0;
}

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

void Main() {
  string s;
  R s;
  string t="";
  rep(i,s.size()) {
    if(isdigit(s[i])) t+=s[i];
    else t=t.substr(0,t.size()-1);
  }
  pr(t);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
 
int main() {
  ll a , b, c;
  cin>>a>>b>>c;
  if(a==b&&a!=c){
    cout<<"Yes"<<endl;
  }
  else if(a==c&&a!=b){
    cout<<"Yes"<<endl;
  }
  else if(a!=b&&b==c){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1];
}

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

int main()
{
	int h,a;
	cin>>h>>a;
	if(h%a)cout<<h/a+1<<endl;
	else cout<<h/a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a; cin>>b;
    int d =a/b;
    int r =a%b;
    double f=double(a)/double (b);
    cout<<d; cout<<" ";
    cout<<r; cout<<" ";
    cout<< fixed << setprecision(5)<< f;
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

vector<string> ans;

void func(ll n,string s)
{
    if(n==0){ans.pb(s);return;}
    set<char> ss;
    for(ll i=0;i<s.length();++i)
    {
        ss.insert(s[i]);
    }
    ll k=ss.size();
    for(ll i=0;i<=k;++i){
        s+=char('a'+i);
        func(n-1,s);
        s.pop_back();
    }
}

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

    ll n;
    cin>>n;
    string s="a";
    func(n-1,s);
    for(auto x:ans){cout<<x<<endl;}

	return(0);
}


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

s_list = list()

for _ in range(M):
    t = list(map(int, input().split() ) )
    k = t[0]
    s = list(t[1:])
    s_list.append(s)

p_list = list(map(int, input().split() ) )

s_mask = list()
for ss in s_list:
    s_bits = 0
    for s in ss:
        s_bits = (s_bits | (1 << (s-1)))
    s_mask.append(s_bits)
        
#print(s_list)
#for m in s_mask:
#    print(bin(m))
find_cnt = 0
for i in range(2 ** N):
    ng_flg = 0
    for k in range(M):
        sum_bits = i & s_mask[k]
        bit_cnt=0
        for kk in range(N):
            bit_cnt = bit_cnt + (sum_bits >> kk)

        #print(k, bin(sum_bits), bit_cnt)
        if bit_cnt % 2 != p_list[k]:
            ng_flg = ng_flg + 1
    
    if ng_flg == 0:
        find_cnt = find_cnt + 1
    #print(s_sum)

print(find_cnt)


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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define pi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vl vector<ll>
#define vii vector<pair<int,int> >
#define vll vector<pair<long long,long long> >
#define pb push_back
#define mp make_pair3

const ll mod=1e9+7;
#define MAX 100000

template<typename T>
void max_self(T &a,T b){
    a = max(a,b);
}

template<typename T>
void min_self(T &a,T b){
    a = min(a,b);
}

ll binexpo(ll a,ll b,ll c){

    if(b==0) return 1;
    else if(b%2==0) return binexpo(((a%c)*(a%c))%c,b/2,c)%c;
    else return ((a%c)*(binexpo(((a%c)*(a%c))%c,b/2,c)%c))%c;
}

int h,w;
char mat[1005][1005];
bool visited[1005][1005];
ll ans = 0;

void solve(int x,int y){

    if(x<0 || x>=h || y<0 || y>=w) return;
    visited[x][y] = true;

    if(x == (h-1) && y == (w-1)){
        ++ans;
        ans = ans % mod;
        return;
    }

    if((y-1)>=0 && mat[x][y-1] == '.' && visited[x][y-1] == false)
        solve(x,y-1);

    if((y+1)<=(w-1) && mat[x][y+1] == '.' && visited[x][y+1] == false)
        solve(x,y+1);

    if((x-1)>=0 && mat[x-1][y] == '.' && visited[x-1][y] == false)
        solve(x-1,y);

    if((x+1)<=(h-1) && mat[x+1][y] == '.' && visited[x+1][y] == false)
        solve(x+1,y);
}

int main(){

    std::ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>h>>w;

    FOR(i,0,h){
        FOR(j,0,w){
            cin>>mat[i][j];
        }
    }

    int dp[h][w];
    memset(dp,0,sizeof(dp));

    dp[h-1][w-1] = 1;
    int flag = 0;
    for(int j = w-2;j>=0;j--){
        if(flag) dp[h-1][j] = 0;
        else if(mat[h-1][j] == '#'){
            flag = 1;
            dp[h-1][j] = 0;
        }
        else if(mat[h-1][j] == '.') dp[h-1][j] = 1;
    }

    flag = 0;
    for(int i = h-2;i>=0;i--){
        if(flag) dp[i][w-1] = 0;
        else if(mat[i][w-1] == '#'){
            flag = 1;
            dp[i][w-1] = 0;
        }
        else if(mat[i][w-1] == '.') dp[i][w-1] = 1;
    }

    for(int i = h-2;i>=0;i--){
        for(int j = w-2;j>=0;j--){
            if(mat[i][j] == '#')
                dp[i][j] = 0;
            else if(mat[i][j] == '.')
                dp[i][j] = ((dp[i+1][j] % mod) + (dp[i][j+1] % mod))%mod;
        }
    }

    cout<<dp[0][0];
    return 0;
}

Measured memory_bytes: 5120
require 'set'

n, m, tax = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }
abc = abc.map {|a, b, c| [a, b, -1*(c-tax)] }

# get adjuscent list
graph = Array.new(n+1) { [] }
r_graph = Array.new(n+1) { [] }
abc.each do |a, b, c|
  graph[a] << b
  r_graph[b] << a
end

# build from_1 from_n
def reachable(s, g)
  q=[s]
  visited = Set.new(q)
  until q.empty?
    from = q.shift
#    next if visited.include?(from) # この一行があると落ちる
    visited.add(from)
    g[from].each do |to|
      next if visited.include?(to)
      visited.add(to)
      q.push(to)
    end
  end

  visited
end

from_1 = reachable(1, graph)
from_n = reachable(n, r_graph)
av = from_1 & from_n
edges=abc.select {|a, b, c| av.include?(a) && av.include?(b) }

#p av
#p edges

# b-f method
updated = false
INF= 10**12
dist = Array.new(n+1, INF)
dist[1]=0
n.times do
  updated = false
  edges.each do |a, b, c|
    next if dist[a]==INF || dist[b] <= dist[a] + c

    dist[b] = dist[a] + c
    updated = true
  end
  break unless updated
end

if updated
  p -1
  exit
end

# answer
p [0, -dist[n]].max




Measured memory_bytes: 5500
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int k; cin>>k;
    ll sum=0;
    f(a,1,k+1) f(b,1,k+1) f(c,1,k+1) sum+=__gcd(a,__gcd(b,c));
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3
n = int(input())
b = 0
t = n
while t > 0:
    t >>= 1
    b += 1
ans = [[0] * n for _ in range(n)]
for k in range(b):
    for i in range(n):
        for j in range(i + 1, n):
            if (i >> k & 1) ^ (j >> k & 1):
                ans[i][j] = k + 1
for i in range(n):
    print(*ans[i][i + 1:], sep=' ')


Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
const int mod= 998244353;
ll tree[maxn<<2];
void build(int o,int l,int r){
	tree[o]=0;
	if(l==r){
		return ;
	}
	else {
		int mid=l+r>>1;
		build(o<<1,l,mid);
		build(o<<1|1,mid+1,r);
		tree[o]=max(tree[o<<1],tree[o<<1|1]);
	}
}
ll query(int o,int l,int r,int x,int y){
	if(x<=l&&y>=r){
		return tree[o];
	}
	int mid=l+r>>1;
	ll ans=0;
	if(mid>=x)ans=max(ans,query(o<<1,l,mid,x,y));
	if(mid<y)ans=max(ans,query(o<<1|1,mid+1,r,x,y));
	return ans;
}
void update(int o,int l,int r,int p,ll v){
	if(l==r){
		tree[o]=v;
	}
	else {
		int mid=l+r>>1;
		if(mid>=p)update(o<<1,l,mid,p,v);
		else if(mid<p)update(o<<1|1,mid+1,r,p,v);
		tree[o]=max(tree[o<<1],tree[o<<1|1]);	
	}
}
pair<ll ,ll>a[maxn];
int L[maxn];
ll b[maxn];
ll dp[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i].first,&a[i].second);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)b[i]=a[i].first;
	build(1,1,n);
	for(int i=n;i>=1;i--){
		int tmp=upper_bound(b+1,b+1+n,a[i].first+a[i].second-1)-b;
		if(tmp==i+1)L[i]=i;
		else L[i]=query(1,1,n,i+1,tmp-1);
		update(1,1,n,i,L[i]);
	}
//	for(int i=1;i<=n;i++)cout<<L[i]<<" ";cout<<endl;
	dp[n+1]=1;
	for(int i=n;i>=1;i--){
		dp[i]=dp[i+1]+dp[L[i]+1];
		dp[i]%=mod;
	}
	printf("%lld\n",dp[1]);
	return 0;
}


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

int main(){
    int d,g;
    cin >> d >> g;
    int p[d], c[d];
    for (int i=0;i<d;i++){
        cin >> p[i] >> c[i];
    }
    int ans = 1e9;
    for (int mask = 0; mask<(1<<d); ++mask){  //1をDビット左シフト=2**dだけ値をかける(全探索)
        int s = 0, num = 0, rest_max = -1;
        for (int i = 0; i < d; ++i){
            if (mask >> i & 1){ //もしmaskのi桁目が1だったら=もしiを全部解くとしたら
                s += 100 * (i+1) * p[i] + c[i]; //得点
                num += p[i]; //解いた数
            }else{
                rest_max = i;
            }
        }
        //もし目標得点に届いていなかったら
        if (s < g){
            int s1 = 100 * (rest_max + 1); //s1は一つの問題の得点
            int need = (g - s + s1 - 1) / s1;
            if (need >= p[rest_max]){
                continue; //無視
            }
            num += need;
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#define MAX_N 100010

vll t(MAX_N, LLINF);
vll s(MAX_N, LLINF);
vll x(MAX_N, LLINF);

bool solve(ll threshold, vll& v, ll mid, bool up){
  if(up)
    return v[mid] >= threshold;
  else
    return v[mid] <= threshold;
}

ll binarySearch(ll threshold, vll& v, ll ok, ll ng, bool up){
  while(abs(ok-ng)>1){
    ll mid = (ok+ng)/2;
    
    if(solve(threshold, v, mid, up))
      ok = mid;
    else
      ng = mid;
  }
  return v[ok];
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b,q;
  cin >> a >> b >> q;
  REP(i, a)
    cin >> s[i];
  REP(i, b)
    cin >> t[i];
  REP(i, q)
    cin >> x[i];
  
  //insert 0, inf
  s[a] = -LLINF;
  t[b] = -LLINF;
  a++;
  b++;
  s[a] = LLINF;
  t[b] = LLINF;
  a++;
  b++;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  
  //most right in leftside, most left in rightside
  pll sPair, tPair;
  vll ans(q, LLINF);
  REP(i, q){
    sPair.FI = binarySearch(x[i], s, 0, a, false);
    sPair.SE = binarySearch(x[i], s, a-1, -1, true);
    tPair.FI = binarySearch(x[i], t, 0, b, false);
    tPair.SE = binarySearch(x[i], t, b-1, -1, true);
    
    ans[i] = min(ans[i], abs(sPair.FI-x[i])+abs(sPair.FI-tPair.FI));
    ans[i] = min(ans[i], abs(sPair.FI-x[i])+abs(sPair.FI-tPair.SE));
    ans[i] = min(ans[i], abs(sPair.SE-x[i])+abs(sPair.SE-tPair.FI));
    ans[i] = min(ans[i], abs(sPair.SE-x[i])+abs(sPair.SE-tPair.SE));
    
    ans[i] = min(ans[i], abs(tPair.FI-x[i])+abs(tPair.FI-sPair.FI));
    ans[i] = min(ans[i], abs(tPair.FI-x[i])+abs(tPair.FI-sPair.SE));
    ans[i] = min(ans[i], abs(tPair.SE-x[i])+abs(tPair.SE-sPair.FI));
    ans[i] = min(ans[i], abs(tPair.SE-x[i])+abs(tPair.SE-sPair.SE));
  
  }
  
  REP(i, q)
    cout << ans[i] << endl;
  
  
  
  
}

Measured memory_bytes: 4480
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int a[150];
int b[150];
int main()
{
	int n;
	scanf("%d",&n);
	char ch[105];
	scanf("%s",ch);
	int x = strlen(ch);
	int max = -1;
	for(int i=0; i<x; i++)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(int j=0; j<=i; j++)
		{
		 	a[ch[j]]++;
		}
		for(int k=i+1; k<x; k++)
		{
			b[ch[k]]++;
		}
		int sum = 0;
		for(int y=97; y<=122; y++)
		{
			if(a[y]!=0 && b[y]!=0) sum++;
		}
		if(sum > max) max = sum;
	} 
	printf("%d\n",max);
	
	return 0;
}

Measured memory_bytes: 128
cost=[-1,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=list(map(int,input().split()))

dp=[None]*(N+1)
dp[0]=''

for i in range(1,N+1):
    for a in A:
        if i-cost[a]>=0 and dp[i-cost[a]]!=None:
            s=dp[i-cost[a]]+str(a)
            if dp[i]==None or len(dp[i])<len(s):
                dp[i]=s
            elif len(dp[i])>len(s):
                continue
            else:
                dp[i]=max(dp[i],s)
            
            
print(dp[N])

Measured memory_bytes: 34528
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    vector<int> arr(5,0);
    F0R(i,5)
        cin >> arr[i];
    F0R(i,5) {
        if(arr[i]==0) {
            cout << i+1;
            return 0;
        }
    }

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<string,P> st;
    rep(i,n){
        string p;
        cin >> p;
        if(st.find(p)!=st.end()) st[p].first+=1;
        else{
            st[p].first=1;
            st[p].second=0;
        }
        
    }
    int m;
    cin >> m;
    rep(i,m){
        string p;
        cin >> p;
        if(st.find(p)!=st.end()) st[p].second+=1;
        else{
            st[p].first=0;
            st[p].second=1;
        }
    }
    int temp = -1;
    for(auto itr=st.begin();itr!=st.end();++itr){
        //if((val.first-val.second)>temp) temp=(val.first-val.second);
        int val;
        val = itr->second.first-itr->second.second;
        temp = max(temp,val);
    }
    cout << max(0,temp) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
const int MAX = 101;
int main(){
  int n;cin>>n;
  int x[n],y[n],h[n];
  r(i,0,n)cin>>x[i]>>y[i]>>h[i];
  r(posX,0,MAX){
    r(posY,0,MAX){
      int needH=-1;
      r(i,0,n){
        if(h[i]>0){
          int tmp=h[i]+abs(posX-x[i])+abs(posY-y[i]);
          if(needH==-1){
            needH=tmp;
          }else if(needH!=tmp){
            needH=-2;
            break;
          }
        }
      }
      if(needH==-2)continue;
      r(i,0,n){
        if(h[i]==0){
          int dst=abs(posX-x[i])+abs(posY-y[i]);
          if(needH>dst){
            needH=-2;
            break;
          }
        }
      }
      if(needH==-2)continue;
      cout<<posX<<" "<<posY<<" "<<needH<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

if A<=C:
  if B >= C:
    if B<=D:
      print(B-C)
    else:
      print(D-C)
  else:
    print(0)
else:
  if D < A:
    print(0)
  else:
    if D <= B:
      print(D-A)
    else:
      print(B-A)
      

Measured memory_bytes: 38256
fn main() {
    let mut first = String::new();
    std::io::stdin().read_line(&mut first).ok();
    let mut it = first.trim().split_whitespace();
    let gates:u32 = it.next().unwrap().parse().unwrap();
    let lines:u32 = it.next().unwrap().parse().unwrap();
    let mut min:u32 = 1;
    let mut max:u32 = gates;
    for _ in 0..lines{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        let mut it = line.trim().split_whitespace();
        let from:u32 = it.next().unwrap().parse().unwrap();
        let to:u32 = it.next().unwrap().parse().unwrap();
        min = if min < from {from} else {min};
        max = if max > to {to} else {max};
        if  max < min{
            break;
        }
    }
    println!("{}",if max < min {0} else {max - min + 1});
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
char a[10];
int cnt[27];
int main() {
	scanf("%s",a);
	for(int i=0;i<4;i++)cnt[a[i]-'A']++;
	bool flg=0;
	for(int i=0;i<26;i++)if(cnt[i]&&cnt[i]!=2)flg=1;
	puts(flg?"No":"Yes");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

using ull = unsigned long long;

ull keta(ull n){
  ull ret = 0;
  while(n >= 10){
    n /= 10;
    ret++;
  }
  return ret;
}

int main(void){
  ll n;
  cin >> n;
  vector<ull> a(n);
  REP(i, n) cin >> a[i];

  REP(i, n){
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  double t = 0;
  REP(i, n) t += log10(a[i]);
  if(t > 18){
    cout << -1 << endl;
    return 0;
  }
  
  ull ans = 1;
  ull k = (ull)(1e18);
  REP(i, n){
    ans *= a[i];
    if(ans > k){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4116
package main

import (
	"fmt"
	"os"
	"math"
)

func main() {
  var n int
  fmt.Fscanf(os.Stdin, "%d", &n)
  
  nums := make([]int, n)
  
  for i:=0; i<n; i++ {
    fmt.Fscanf(os.Stdin, "%d", &nums[i])
  }
  
  fmt.Println(Count(nums))
}

func Count(nums []int) int {
  if len(nums) <= 1 {
    return 0
  }
  n := len(nums)
  
dp := make([]int, n)

	dp[0] = 0
	dp[1] = abs(nums[1] - nums[0])
  for i:= 2; i<n; i++ {
	  dp[i] = min(dp[i-1] + abs(nums[i-1] - nums[i]), dp[i-2] + abs(nums[i-2] - nums[i]))
	  // fmt.Println(dp[i])
  }
	
  return dp[n-1]
}

func min(x, y int) int {
  if x < y {
    return x
  }
  return y
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, S = 0;
    cin >> N;
    vector<int> A(N + 2, 0);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        S += abs(A[i] - A[i - 1]);
    }
    S += abs(A[N + 1] - A[N]);
    for (int i = 1; i <= N; i++) {
        cout << S - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]) << endl;
    }
}


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


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

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

	vector<ll> sums;
	for(int i=0;i<N;i++) {
		ll s = 0;
		for(int j=i;j<N;j++) {
			s += a[j];
			sums.push_back(s);
		}
	}

	ll top_bit = 1LL << 62;
	ll ans = 0;
	vector<bool> dead(sums.size(), false);
	while(top_bit > 0) {
		int k = 0;
		for(int i=0;i<sums.size();i++) {
			if (dead[i]) continue;
			if (sums[i]&top_bit) {
				k++;
			}
		}
		if(k >= K) {
			ans += top_bit;
			for (int i = 0; i<sums.size(); i++) {
				if (dead[i]) continue;
				if ((sums[i] & top_bit) == 0) {
					dead[i] = true;
				}
			}
		}
		top_bit >>= 1;
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  long long N;
  cin >> N;
  if (N % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  long long sum = 0;
  for (long long i = 10; i <= N; i = i * 5) {
    sum += N / i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int i;
    cin >> s;

    for( i=0; i<s.size(); i++)
    {
        if(s[i]=='7')
        {

            cout<<"Yes";
            return 0;
        }

    }
    cout<<"No";
}


Measured memory_bytes: 3636
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
	int a, b, c;
	cin >> a;
	if (a / 100 != 7)
	{
		a %= 100;
		if (a / 10 != 7)
		{
			a %= 10;
			if (a != 7)
			{
				printf("No");
				return 0;
			}

		}
	}

	cout << "Yes" << endl;
	cin >> b;
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
 
int main(){
    long long int N;
    cin >> N;

    cout << (N - 2) * 180 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a, b, c, d; 
  cin >> a >> b >> c >> d;

  ll ans=a*c;

  if(ans < a * c)
    ans = a * c;
  if(ans < a * d)
    ans = a * d;
  if(ans < b * c)
    ans = b * c;
  if(ans < b * d)
    ans = b * d;

  cout << ans << endl;

  return 0;
}


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

int main() {
  int32_t H = 0, W = 0;
  std::cin >> H >> W;
  std::vector<std::string> grid(H);
  for (auto &&g : grid) std::cin >> g;
  for (int32_t h = 0; h < H; h++) {
    for (int32_t w = 0; w < W; w++) {
      if (grid[h][w] == '#') {
        for (int32_t i = h - 1; i <= h + 1; i++) {
          if (i < 0 || i >= H) continue;
          for (int32_t j = w - 1; j <= w + 1; j++) {
            if (j < 0 || j >= W || grid[i][j] == '#') continue;
            grid[i][j] = (grid[i][j] == '.' ? '1' : grid[i][j] + 1);
          }
        }
      } else if (grid[h][w] == '.') {
        grid[h][w] = '0';
      }
    }
  }

  for (auto &&g : grid) std::cout << g << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll cnt1,cnt2,cnt3;
  cnt1=cnt2=cnt3=0;
  cnt1=min(k,a);
  k-=cnt1;
  cnt2=min(k,b);
  k-=cnt2;
  cnt3=min(k,c);
  ll ans = cnt1-cnt3;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];


int main()
{
    ll n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>n>>x;

    ll ans = n;
    n-=x;

    while(n%x){
        ans+=x*(n/x)*2;
        y = x;
        x = n%x;
        n = y;
    }

    ans+=x*(n/x)*2-x;

    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long long n,l,r,sum=0;
cin >> n;
for(int i=1;i<=n;i=i+1)
{
cin >> l >> r;
//cout << endl;
sum=sum+1-l+r;
}
cout << sum << endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
import copy
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
for i in range(M):
    p,x = map(int,input().split())
    P.append([p,x])
ans = sum(T)
for i in P:
    X = copy.copy(T)
    X[i[0]-1] = i[1]
    ans = sum(X)
    print(ans)

Measured memory_bytes: 38512
N, M, R = map(int, input().split())
T = list(map(int, input().split()))
D = [[float('INF')] * N for _ in range(N)]
V = [False] * R
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    if D[A][B] > C:
        D[A][B] = C
        D[B][A] = C
ans = float('INF')


def dfs(c, s, d):
    global ans
    if c == R + 1:
        if ans > d:
            ans = d
            return

    for i in range(R):
        if V[i] is True:
            continue
        V[i] = True
        if s == -1:
            dfs(c + 1, i, 0)
        else:
            dfs(c + 1, i, d + D[T[s] - 1][T[i] - 1])
        V[i] = False


def main():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                D[i][j] = min(D[i][j], D[i][k] + D[k][j])
    dfs(1, -1, 0)
    print(ans)


main()


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

int main() {
  ll n, m; cin >> n >> m;
  ll ans = min(n, m/2);
  if (ans == n) {
    m -= 2*ans;
    ans += m/4;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int tbl[9] = {};
	for(int i = 0; i < 3; ++i)
	for(int j = 0; j < 3; ++j){
		int t = i * 3 + j;
		if(i != 0){
			int u = t - 3;
			tbl[t] |= 1 << u;
			tbl[u] |= 1 << t;
		}
		if(j != 0){
			int u = t - 1;
			tbl[t] |= 1 << u;
			tbl[u] |= 1 << t;
		}
	}
	
	string s;
	while(cin >> s){
		bool ok = true;
		for(int i = 1; i < s.size(); ++i){
			if(!(tbl[s[i - 1] - 'A'] >> (s[i] - 'A') & 1)){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << s << '\n';
		}
	}
}

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

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

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

  int ans = 1;
  for (int i = 1; i < n; i++){
    int max_h = 0;
    for (int j = 0; j < i; j++) {
      max_h = max(max_h, h[j]);
    }
    if(h[i] >= max_h){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
  ll ans=0;
  double under=0;
  for(ll i=0;i<N;i++) {
    double x;
  string u;
    cin>>x>>u;
    
    if(u=="JPY") {
ans+=x;
    }
    else {
      ll a=x;
      ans+=a*380000;
      
      x-=a;
      x*=380000;
      ll b=x;
      ans+=x;
      under+=x-b;
    }
  }
  
  cout<<ans+under<<endl;
}

    
  
  


Measured memory_bytes: 3704
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			scanner.nextLine();
			int[] l = new int[n];
			IntStream.range(0, n).forEach(i -> {
				l[i] = scanner.nextInt();
				scanner.nextLine();
			});
			System.out.println(dfs(0, 0, 0, 0, n, a, b, c, l));
		}
	}

	private static long dfs(int cur, int d, int e, int f, int n, int a, int b, int c, int[] l) {
		if (cur == n) {
			if (min(d, e, f) > 0) {
				return Math.abs(d - a) + Math.abs(e - b) + Math.abs(f - c) - 30;
			} else {
				return Integer.MAX_VALUE;
			}
		}
		long ret0 = dfs(cur + 1, d, e, f, n, a, b, c, l);
		long ret1 = dfs(cur + 1, d + l[cur], e, f, n, a, b, c, l) + 10;
		long ret2 = dfs(cur + 1, d, e + l[cur], f, n, a, b, c, l) + 10;
		long ret3 = dfs(cur + 1, d, e, f + l[cur], n, a, b, c, l) + 10;
		return min(ret0, ret1, ret2, ret3);
	}

	private static int min(int... x) {
		return Arrays.stream(x).min().getAsInt();
	}

	private static long min(long... x) {
		return Arrays.stream(x).min().getAsLong();
	}
}


Measured memory_bytes: 47664
n = int(input())
p = list(map(int,input().split()))

ex = list(range(1,n+1))

for i in range(n):
    for j in range(n):
        tmp = p.copy()
        tmp_i = tmp[i]
        tmp[i] = tmp[j]
        tmp[j] = tmp_i
        for k in range(n):
            cnt = 0
            if(ex[k] != tmp[k]):
                cnt += 1
                break
        if(cnt == 0):
            print('YES')
            exit()

print('NO')

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  bool ok = true;
  rep(i, n - 1) {
    if (h[i] < h[i + 1]) {
      h[i + 1]--;
    }
    if (h[i] > h[i + 1]) {
      ok = false;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3744