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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 11;
const ll INF = 1ll << 60;

ll n;
ll a[e5];
ll ans;
vector<vl> op;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> a[i];
  sort(a,a+n);
  if(a[0] < 0 && a[n-1] < 0){
    for(ll i = 0;i < n-1;i++){
      ans += abs(a[i]);
    }
    ans += a[n-1];
    cout << ans << endl;
    for(ll i = 0;i < n-1;i++){
      cout << a[n-1] << " " << a[i] << endl;
      a[n-1] = a[n-1] - a[i];
    }
  }else if(a[0] < 0 && a[n-1] >= 0){
    for(ll i = 0;i < n;i++){
      ans += abs(a[i]);
    }
    cout << ans << endl;
    for(ll i = 1;i < n-1;i++){
      if(a[i] < 0){
        cout << a[n-1] << " " << a[i] << endl;
        a[n-1] = a[n-1] - a[i];
      }else{
        cout << a[0] << " " << a[i] << endl;
        a[0] = a[0] - a[i];
      }
    }
    cout << a[n-1] << " " << a[0] << endl;
  }else if(a[0] >= 0 && a[n-1] >= 0){
    for(ll i = 1;i < n;i++){
      ans += abs(a[i]);
    }
    ans -= a[0];
    cout << ans << endl;
    for(ll i = 1;i < n-1;i++){
      cout << a[0] << " " << a[i] << endl;
      a[0] = a[0] - a[i];
    }
    cout << a[n-1] << " " << a[0] << endl;
  }
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> pii;

const int MAX_N = 50010;

bool dp[MAX_N];

int x[50000];
int sum[50001];
int w,n;

inline bool ok2(int a, int b) { // [a,b]をぎりぎりで詰めたときwに入るかどうか
  int num = b-a+1;
  int space = num-1;
  // cout << "ok2 : " << a << "," << b << " : " << sum[b+1]-sum[a]+space << endl;
  return sum[b+1]-sum[a] + space <= w;
}

inline bool ok3(int a, int b, int m) {        // [a,b]を余裕を持って詰めたとき幅m以下でwを埋めれるかどうか
  int num = b-a+1;
  int space = (num-1) * m;
  // cout << "ok3 : " << a << "," << b << " : " << sum[b+1]-sum[a]+space << endl;
  return sum[b+1]-sum[a]+space >= w;
}

bool ok(int m) {
  if (ok2(0,n-1)) return 1;
  int a = 0, b = 0;
  int cnt = 0;
  // REP(i,n+1)dp[i]=0;
  // memset(dp,0,sizeof(dp));
  // cout << "m = " << m << endl;
  dp[0] = 1;
  REP(i,n) {
    while(a<=i&&!ok2(a,i)) {
      if (dp[a]) cnt--;
      a++;
    }
    while(b<=i&&ok3(b,i,m)) {
      if (dp[b]) cnt++;
      b++;
    }
    // cout <<  i << " : " << a << " " << b << " "  << cnt << endl;
    if (cnt) {
      dp[i+1] = 1;
      if (ok2(i+1,n-1)) return 1;
    } else {
      dp[i+1] = 0;
    }
  }
  return 0;
}

int main() {
  while(scanf("%d%d",&w,&n),w||n) {
    REP(i,n) scanf("%d",x+i);
    REP(i,n) sum[i+1] = sum[i] + x[i];
    int low=0,high=w;
    while(low+1<high) {
      int mid = (low + high) / 2;
      if (ok(mid)) high = mid;
      else low = mid;
    }
    cout << high << endl;
  }
}

Measured memory_bytes: 1648
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	x := getNextInt(scanner)
	a := getNextInt(scanner)

	if x < a {
		fmt.Fprintln(writer, 0)
	} else {
		fmt.Fprintln(writer, 10)

	}

	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int a[3][3];
	REP(i,3)REP(j,3) cin>>a[i][j];
	
	int n;
	cin>>n;
	
	map<int,int> mp;
	REP(i,n){
		int b;
		cin>>b;
		mp[b]=1;
	}
	
	bool jud[3][3]={};
	REP(i,3)REP(j,3){
		if(mp[a[i][j]]) jud[i][j]=1;
	}
	
	if(jud[0][0] and jud[1][1] and jud[2][2]){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if(jud[0][2] and jud[1][1] and jud[2][0]){
		cout<<"Yes"<<endl;
		return 0;
	}
	
	REP(i,3){
		if(jud[i][0] and jud[i][1] and jud[i][2]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	REP(i,3){
		if(jud[0][i] and jud[1][i] and jud[2][i]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
}

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

int main() {
	int n, a[200000], min;
	long long int ben = -10000000000;

	cin >> n;

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

	for (int i = 0; i < n; i++) {
		if (i) {
			if (ben < a[i] - min) ben = a[i] - min;

			if (min > a[i]) min = a[i];
		}
		else min = a[i];
	}

	cout << ben << endl;

	return 0;
}

Measured memory_bytes: 1936
n, a, b, k = [int(i) for i in input().split()]
p = 998244353

def fact(n, p):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

f = list(fact(n+1, p))
rf = list(invfact(n+1, f, p))
rf.reverse()
ans = 0

for x in range(n+1):
    y = (k-x*a)/b
    if not y.is_integer() or y > n or y < 0:
        continue
    y = int(y)

    ans += (f[n] * rf[x] % p * rf[n-x] % p) * (f[n] * rf[y] % p * rf[n-y] % p) % p

print(ans%p)

Measured memory_bytes: 26788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

ll n, m, ans, d;

int main(){
    cin >> n >> m;
    vector<ll> x(m), l(m - 1);
    for (int i = 0; i < m; i++) cin >> x[i];
    sort(x.begin(), x.end());
    for (int i = 0; i + 1 < m; i++) d = abs(x[i] - x[i + 1]), ans += d, l[i] = d;
    sort(l.begin(), l.end(), greater<ll>());
    d = min(n - 1, m - 1);
    for (int i = 0; i < d; i++) ans -= l[i];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int n;
  vector<int> v;
  cin >> n;
  long long sum = 0;
  for (int i=0;i<n;++i) {
    int x;
    cin >> x;
    v.push_back(x);
    sum += x;
  }
  double ave = sum / (double)n;
  int ans; double min_diff=0xfffffff;
  for (int i=0; i<n; ++i) {
    double diff = abs(ave - v[i]);
    if (diff < min_diff) {
      ans = i;
      min_diff = diff;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n";
#define ll long long
ll MOD = 10e9 + 7;

int main() {
    int n,k;
    string s;
    cin >> n;
    cin >> s;
    cin >> k;
    --k;
    REP(i, n) {
        if(s[k] != s[i]) s[i] = '*';
    }
    OUT(s);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,sum=0;
  int V[20]={0},C[20]={0};
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  for(int i=0;i<N;i++){
    if(V[i]>C[i])sum+=V[i]-C[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int m[10];
    for(int i = 0; i < 10; i++)
    {
        cin >> m[i];
    }

    sort(m, m+10, greater<int>());

    for(int i = 0; i < 3; i++)
        cout << m[i] << endl;
}



Measured memory_bytes: 3108
#include <iostream>
#include<queue>
#include<string.h>
using namespace std;
#define TATE 1
#define YOKO 0

struct ST {
        int x;
        int y;
    };

int main(void){
    int map[101][101];
    int board[101][101];
    int T[]={0,-1,1,0};
    int Y[]={1,0,0,-1};
    int w,h,xs,xg,ys,yg,n,color,muki,x,y;
    
    ST RE;
    ST GO;
    queue <ST> Q;
    while(1){
        memset(map,0,sizeof(map));
        memset(board,0,sizeof(board));
        cin>>w>>h;
        if(w==0&&h==0)break;
        cin>>xs>>ys>>xg>>yg>>n;
        for(int i=0;i<n;i++){
            cin>>color>>muki>>x>>y;
            if(muki==YOKO){
                for(int j=0;j<4;j++){
                    board[y][x+j]=board[y+1][x+j]=color;
                }
            }
            else{
                for(int j=0;j<4;j++){
                    board[y+j][x]=board[y+j][x+1]=color;
                }
            }
        }
       /* for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cout<<board[i][j];
            }
            cout<<endl;
        }*/
        RE.x=xs;
        RE.y=ys;
        map[ys][xs]=1;
        Q.push(RE);
        int flag=0;
        while(!Q.empty()){
            RE=Q.front();
            Q.pop();
            if(RE.x==xg&&RE.y==yg&&board[RE.y][RE.x]==board[yg][xg]){
                flag=1;
                //cout<<RE.x<<" "<<RE.y<<endl;
                break;
            }
            else{
                for(int i=0;i<4;i++){
                    GO=RE;
                    if(GO.x+Y[i]>0&&GO.y+T[i]>0&&GO.x+Y[i]<101&&GO.y+T[i]<101&&board[GO.y+T[i]][GO.x+Y[i]]==board[GO.y][GO.x]&&map[GO.y+T[i]][GO.x+Y[i]]!=1){
                        GO.x+=Y[i];
                        GO.y+=T[i];
                        map[GO.y][GO.x]=1;
                        Q.push(GO);
                    }
                }
            }
        }
       /* for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<board[i][j];
            }
            cout<<endl;
        }*/
        if(flag==1){
            cout<<"OK"<<endl;
        }
        else{
            cout<<"NG"<<endl;
        }
    }
    
}



Measured memory_bytes: 3088
# coding: utf-8

import sys
import math
import fractions
import heapq
import collections
import re
import array
import bisect
sys.setrecursionlimit(1000000)

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))


II = lambda: int(input())
MI = lambda: map(int, input().split())



def main():
    N, M = MI()
    in_edges = [set() for _ in range(N)]
    out_edges = [set() for _ in range(N)]
    num_in_edges = [0] * N
    for _ in range(N - 1 + M):
        a, b = MI()
        a -= 1
        b -= 1
        num_in_edges[b] += 1
        in_edges[b].add(a)
        out_edges[a].add(b)
    Root = argmin(num_in_edges)
    parent = [0] * N
    parent[Root] = -1

    q = [Root]

    while q:
        v = q.pop()
        for child in out_edges[v]:
            in_edges[child].remove(v)
            num_in_edges[child] -= 1
            if num_in_edges[child] == 0:
                parent[child] = v
                q.append(child)

    for p in parent:
        print(p + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		
		var a = Input().Select(long.Parse).ToArray();
		long sa = 0;
		for(int i = 1; i < n; i++)
		{
			if(a[i-1] > a[i])
			{
				sa += a[i-1]-a[i];
				a[i] = a[i-1];
			}
			
		}
		Console.WriteLine(sa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 47760
n=int(input())
m = {}
cnt = [0] * (n+1)
edges = []

for i in range(n-1):
    a,b=map(int, input().split())
    edges.append((a, b))
    m[a] = m.get(a, set())
    m[a].add(b)
    m[b] = m.get(b, set())
    m[b].add(a)
    cnt[a] += 1
    cnt[b] += 1

c = list(sorted(map(int, input().split())))

from collections import deque

q = deque()
current = 0
ans = [0] * (n+1)
for i in range(1, n+1):
    if cnt[i] == 1:
        q.append(i)

while q:
    node = q.pop()
    ans[node] = c[current]
    current += 1
    for i in m[node]:
        cnt[i] -= 1
        if cnt[i] == 1:
            q.append(i)

print(sum(min([ans[i[0]], ans[i[1]]]) for i in edges))
for i in range(1, n+1):
    print(ans[i])

Measured memory_bytes: 8592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int n,k;
vector<int> edge[2001];
vector<pair<int,int> > hen;


int bfs(int start,int start2, int maxCou){
    queue<pair<int, int> > que;
    que.push(make_pair(start, 0));
    if(start2 != -1) que.push(make_pair(start2, 0));
    bool used[2001] = {};
    
    int count = 0;
    
    while(que.size()){
        int now = que.front().first;
        int cou = que.front().second;
        que.pop();
        
        if(used[now]) continue;
        if(cou > maxCou) continue;
        used[now] = true;
        count++;
        
        for(int i = 0;i < edge[now].size();i++){
            que.push(make_pair(edge[now][i], cou + 1));
        }
    }
    
    return n - count;
}

int main(void){
    cin >> n >> k;
    int a,b;
    for(int i = 0;i < n-1;i++){
        cin >> a >> b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
        hen.push_back(make_pair(a,b));
    }
    
    int ans = INF;
    
    if(k % 2 == 0){
        for(int i = 0;i < n-1;i++){
            ans = min(ans, bfs(i, -1, k/2));

       }
    }else{
        for(int i = 0;i < hen.size();i++){
            a = hen[i].first;
            b = hen[i].second;
            ans = min(ans,bfs(a,b,k/2));
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int a, b;
    cin >> a >> b;
    cout << (a + b == 3 ? 3 : (a + b == 4 ? 2 : 1));
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

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

  int odd = 0;
  if(N % 2){
    odd = (N / 2) + 1;
  }else{
    odd = N / 2;
  }

  cout << fixed;
  cout << setprecision(10) << (double)odd / N << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

int main(void)
{
	int i, j, k, n, min, temp, r[MAX+1], m[MAX][MAX];
	
	scanf("%d",&n);
	for (i=0; i<n; i++) {
		scanf("%d %d",&r[i], &r[i+1]);
	}
	
	for (i=0; i<n; i++) {
		m[i][i] = 0;
	}
	
	for (i=1; i<n; i++) {
		for (j=0; j<n-i; j++) {
			for (k=j; k<j+i; k++) {
				temp = m[j][k] + m[k+1][j+i] + r[j]*r[k+1]*r[j+i+1];
				if (k==j || min > temp) min = temp;
			}
			m[j][j+i] = min;
		}
	}
	
	printf("%d\n",m[0][n-1]);
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n,k,l;
ll ans[mx];
int v[mx],r[mx];

int find(int x){
  if( v[x] != x){ v[x] = find(v[x]); }
  return v[x];
}
int findr(int x){
  if( r[x] != x){ r[x] = findr(r[x]); }
  return r[x];
}

void merge(int x, int y){
  x = find(x);
  y = find(y);
  v[y] = x;
}
void merger(int x, int y){
  x = findr(x);
  y = findr(y);
  r[y] = x;
}


int main() {
  cin >> n >> k >> l;
  for(int i=0; i<n; i++){v[i]=i;}
  for(int i=0,a,b; i<k; i++){ 
    cin >> a >> b;
    merge(a,b);
  }
  
  for(int i=0; i<n; i++){r[i]=i;}
  for(int i=0,a,b; i<l; i++){ 
    cin >> a >> b;
    merger(a,b);
  }
  

  map<P,int> mp;	//<<road source, train source>, count>
  for(int i=1; i<=n; i++){ mp[{find(i),findr(i)}]++; }	//i-city sources. if source same, +1
  for(int i=1; i<=n; i++){ cout << mp[{find(i),findr(i)}] << " "; }
  cout << endl; 
  return 0;
}  


Measured memory_bytes: 13568
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

template<ll MOD> class MInt {
  ll value;
public:
  MInt() : value(0) {}
  MInt(int v) : value(v) {}
  MInt(ll v) : value(v) {}
  MInt& operator+=(const MInt<MOD> &r) {
    value += r.value; if (value > MOD) value -= MOD; return *this;
  }
  MInt& operator-=(const MInt<MOD> &r) {
    value -= r.value; if (value < 0) value += MOD; return *this;
  }
  MInt& operator*=(const MInt<MOD> &r) {
    value *= r.value; value %= MOD; return *this;
  }
  MInt& operator/=(const MInt<MOD> &r) {
    (*this) *= r.inv(); return *this;
  }
  MInt operator+(const MInt<MOD> &r) const { MInt result = *this; result += r; return result; }
  MInt operator-(const MInt<MOD> &r) const { MInt result = *this; result -= r; return result; }
  MInt operator*(const MInt<MOD> &r) const { MInt result = *this; result *= r; return result; }
  MInt operator/(const MInt<MOD> &r) const { MInt result = *this; result /= r; return result; }
  MInt pow(ll p) const {
    MInt result = 1, x = *this;
    for (;p;p >>= 1) {
      if (p & 1) result *= x;
      x *= x;
    }
    return result;
  }
  MInt inv() const { return this->pow(MOD - 2); }
  operator ll() const { return value; }
  
};

typedef MInt<1000000007> Int;

class C_cls {
  static const int N = 1000000;
  vector<Int> facts;
public:
  C_cls() : facts(vector<Int>(N, 1)){
    FOR(i,1,N) facts[i] = facts[i-1] * Int(i);
  }
  Int choose(int n, int r) { return facts[n] / (facts[r] * facts[n-r]); }
};

C_cls C;

const int L = 200000;

Int lsum(int l) { return Int(3).pow(l); }

Int rec(const string &s, int head, int length) {
  if (length == 0) return 1;
  if (s[head] == '0') return rec(s, head + 1, length - 1);
  Int result = rec(s, head + 1, length - 1) * Int(2);
  result += lsum(length - 1);
  return result;
}

int main() {
  string s;
  while (cin >> s) {
    Int result = rec(s, 0, s.length());
    cout << result << endl;
  }
}


Measured memory_bytes: 11456
n = int(input())
s = list(input())
half = int(n/2)

max1 = 0
for i in range(half):
  f = set(s[:half-i])
  b = set(s[half-i:])
  union = len(f&b)
  if max1 < union:
    max1 = union
  #else:
    #break

max2 = 0
for i in range(half):
  f = set(s[:half+i])
  b = set(s[half+i:])
  union = len(f&b)
  if max2 < union:
    max2 = union
  #else:
    #break
    
ans = max1 if max1>max2 else max2
print(ans)

Measured memory_bytes: 62176
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
ll n,i,l;
cin>>n>>l;
ll arr[n+1],c=100000000000,s=0;
for(i=0;i<n;i++)
{
    arr[i]=l+i;
    if(abs(arr[i])<abs(c))
        c=arr[i];
    s=s+arr[i];
}
cout<<s-c<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long a, long long b) {
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long b;
  long long a;
  cin >> a;
  cin >> b;
  solve(a, b);
  return 0;
}


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PF push_front
#define PB push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())
#define ALL(v) (v).begin(), (v).end()

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in() {int x; std::cin >> x; return x;}
 
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

int gcd(int a, int b){ int c; while (a != 0){ c = a; a = b % a; b = c; } return b; }

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

  char f = 'a';
  bool flg = false;
  string a, b, c;
  cin >> a >> b >> c;

  while (1){
    int i = 0;
    if (f == 'a'){
      while (a[i] == '0') i++;
      f = a[i];
      if (a[i] == '\0'){
        print("A");
        flg = true;
        break;
      }
      a[i] = '0';
    }
    else if (f == 'b'){
      while (b[i] == '0') i++;
      f = b[i];
      if (b[i] == '\0'){
        print("B");
        flg = true;
        break;
      }
      b[i] = '0';
    }
    else if (f == 'c'){
      while (c[i] == '0') i++;
      f = c[i];
      if (c[i] == '\0'){
        print("C"); 
        flg = true;
        break;
      } 
      c[i] = '0';
    }
    if (flg) break;
  }

  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

int numofbits5(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main()
{
    int n;
    cin >> n;
    long long int total = 0;
    std::vector<int> a;
    std::vector<int> x;

    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
        //x.push_back(numofbits5(tmp));
        total = total^tmp;
    }
    int tmp;
    for(int i=0; i<n; i++){
        
        tmp = total ^ a[i];
        //cout << std::bitset<8>(tmp) << endl;
        
        if(i == n-1) cout << tmp;
        else cout << tmp << " ";

    }
    cout << endl;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  
  ll n;cin>>n;
  ll a[n];
  ll sum = 0;
  for(int i=0;i<n;i++){cin>>a[i];sum^=a[i];}
  
  for(int i=0;i<n;i++){

    int gg = a[i]^sum;
    cout<<gg<<" ";
  }
  
  
  return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0);
    int  a,b;
    cin>>a>>b;
    if(a>b){
        swap(b,a);
    }
    if(b-a==a){
        cout<<b+a;
    }
    else{
        cout<<b-a;
    }
    return 0;
}



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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;i<(n);i++)
#define vecadd emplace_back

typedef pair<int,int> P;

int main(){
  int a,b;
  
  cin>>a>>b;
  
  int n=(b-1)/(a-1);
  
  if((b-1)%(a-1)==0){}
  else n++;
  
  cout<<n;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[305];
int n,m,k,a[305],b[305];
ll d[305][305][305],ans,mod = 998244353;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> s+1 >> k;
    m = strlen(s+1);
    n = 1;
    for(int i = 1;i <= m;i++) {
        if(s[i] == '0') n++;
        else a[n]++;
    }
    n++;
    for(int i = n-1;i >= 0;i--) {
        b[i] = b[i+1]+a[i];
    }

    k = min(b[1],k);
    d[0][0][0] = 1;
    for(int i = 1;i <= n;++i) {
        for(int c = 0;c <= a[i];c++) {
            for(int j = c;j <= k;j++) {
                for(int l = j;l <= k;l++) {
                    d[i][l][j-c] = (d[i][l][j-c]+d[i-1][l][j])%mod;
                }
            }
        }
        for(int c = 1;c <= k;++c) {
            for(int j = k-c;j >= 0;j--) {
                for(int l = 0;l <= j;l++) {
                    d[i][j+c][l+c] = (d[i][j+c][l+c]+d[i-1][j][l])%mod;
                }
            }
        }
    }
    for(int i = 0;i <= k;i++) ans += d[n][i][0];
    cout << ans%mod;
    return 0;
}


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

using namespace std;

/*int main() {
	int n, q;
	cin >> n >> q;
	vector<int> q(1000);

	
	
	int a,t;
	string x;
	cin >> a;
	cin >> a >> t;
	if (a == 0) {
		q[a]+=
	}
	
	
	
}*/

int main() {
	while (1) {
		int a, b, c;
		int point;
		cin >> a >> b >> c;
		if (a == -1 && b == -1 && c == -1)break;
		if (a == -1 || b == -1)cout << "F" << endl;
		else {
			point = a + b;
			if (point >= 80) {
				cout << "A" << endl;
			}
			else if (point >= 65) {
				cout << "B" << endl;
			}
			else if (point >= 50) {
				cout << "C" << endl;
			}
			else if (point >= 30) {
				if (c >= 50)cout << "C"<<endl;
				else cout << "D"<<endl;
			}
			else cout << "F"<<endl;
		}
	}
}




Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	if (n % 2) {
		cout << "NA" << endl;
		return 0;
	}
	int x[110], y[110];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	set<P> s;
	for (int i = 0; i < n/2; i++) {
		s.insert(P(x[i]+x[i+n/2], y[i]+y[i+n/2]));
	}
	if (s.size() == 1) {
		P p = *s.begin();
		printf("%.20f %.20f\n", (double)(p.first)/2, (double)(p.second)/2);
	} else {
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 1208
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>

using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while (x!=NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    }
    else {
      x = x->right;
    }
  }

  z->parent = y;

  if (y==NIL) {
    root = z;
  }
  else {
    if (z->key < y->key) {
      y->left = z;
    }
    else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u==NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    cin >> com;
    if (com=="insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 26772
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    string odd, even;
    cin >> odd >> even;
    for (int i = 0; i < odd.size() + even.size(); ++i) {
        if (i % 2 == 1) {
            cout << even[i / 2];
        }  else {
            cout << odd[i / 2];
        }
    }
    cout << "\n";

}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
using System;


public class B
{	
	public static void Main()
	{	
		bool[] exist = new bool[1000001];  // false
		
		int s = Int32.Parse(Console.ReadLine());
		int a = s;
		exist[a] = true;
		for(int i = 2; ; i++)
		{
			a = ((a % 2) == 0) ? (a / 2) : (3 * a + 1);
			if(exist[a])
			{
				Console.WriteLine(i);
				break;
			}
			else
			{
				exist[a] = true;
			}			
		}
	}
}

Measured memory_bytes: 13176
import re

s = input()
n = len(s)
k = int(input())
l = []
for i in range(26):
  m_list = [m.start() for m in re.finditer(chr(ord('a')+i), s)]
  #print(m_list)
  
  for start in m_list:
    c=1
    while start + c <= n and c <= 5:
      if not s[start:start+c] in l:
        l.append(s[start:start+c])
      c += 1
  if len(l) >= k:
    break
#print(l)
print(sorted(l)[k-1])
    


Measured memory_bytes: 40048
N, MOD = int(input()), 10**9+7
memo = [{} for i in range(N+1)]
# Keyが直前の三文字、Valueが作れる文字列の数
# ↑これを文字列の今の長さごとにメモする
# memo[6]['TTT']には直前の三文字がTTTで、
# 6文字目以降の条件に合う文字列の総数が入ってる


# めも化再帰
def dfs(index,last3):
	if last3 in memo[index]:
		return memo[index][last3]
	if index == N:
		return 1
	c_next = 'AT'
	if last3[1:] != 'AC':
		c_next += 'G'
	if ('AG' in last3) == False:
		if  last3[1:] != 'GA':
			if last3[0]+last3[2] != 'AG':
				c_next += 'C'
	count = 0
	for c in c_next:
		count += dfs(index+1,last3[1:]+c)
		count %= MOD

	memo[index][last3] = count
	return count

print(dfs(0,'TTT'))


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;

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

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N = in;
    vector<int> A(N);
    rep( i, N ) A[i] = in;

    vector<int> L(N), R(N);
    for( int i=1  ; i< N; i++ ) L[i] = gcd(L[i-1], A[i-1]);
    for( int i=N-2; i>=0; --i ) R[i] = gcd(R[i+1], A[i+1]);

    int ans = 0;
    rep( i, N ) ans = max( ans, gcd(L[i],R[i]) );

    cout << ans << "\n";
}


Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll n;
    cin >> n;

    vector<int> a,b;
    REP(i,n){
        ll tmp1,tmp2;
        cin >> tmp1 >> tmp2;
        a.push_back(tmp1);
        b.push_back(tmp2);
    }

    ll total = 0;
    REPD(i,n){
        ll tmp = (b[i] - (a[i]+total)%b[i]);
        if(tmp != b[i]){
            total += tmp;
        }
        /*
        if(b[i] == 1){
            total--;
        }
        */
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 4224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABBQEasy solver = new ABBQEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABBQEasy {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Integer[] l = new Integer[2 * n];
            for (int i = 0; i < 2 * n; i++) {
                l[i] = in.nextInt();
            }

            Arrays.sort(l);

            int answer = 0;
            for (int i = 0; i < n; i++) {
                answer += l[2 * i];
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 20948
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<set>
#include<functional>
#include<queue>
using namespace std;

unordered_map<string, char>U;
string x[] = {
"101",
"000000",
"000011",
"10010001",
"010001",
"000001",
"100101",
"10011010",
"0101",
"0001",
"110",
"01001",
"10011011",
"010000",
"0111",
"10011000",
"0110",
"00100",
"10011001",
"10011110",
"00101",
"111",
"10011111",
"1000",
"00110",
"00111",
"10011100",
"10011101",
"000010",
"10010010",
"10010011",
"10010000"
};
string y = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
	for (int i = 0; i < y.length(); i++) {
		U[x[i]] = y[i];
	}
	string a;
	while (getline(cin, a)) {
		string b;
		for (char c : a) {
			int d = 0;
			switch (c) {
			case ' ':d = 26; break;
			case '.':d = 27; break;
			case ',':d = 28; break;
			case '-':d = 29; break;
			case '\'':d = 30; break;
			case '?':d = 31; break;
			default:d = c - 'A';
			}
			for (int i = 4; i >= 0; i--) {
				if (d&(1 << i))b += "1";
				else b += "0";
			}
		}
		int now = 0;
		b += "#########################################################################################";
		for (int i = 0; i < 100; i++) {
			for (int j = 3; j < 10; j++) {
				if (U[b.substr(now, j)] != 0) {
					cout << U[b.substr(now, j)];
					now += j;
					break;
				}
			}
		}
		puts("");
	}
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int N, M, X, Y;
  bool war = false;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  
  for(int i = 0; i< N; i++){
    cin >> x[i];
  }
  for(int i = 0; i< M; i++){
    cin >> y[i];
  }

  for (int i = X + 1; i < Y + 1; i++) {
    for (int j = 0; j < N; j++) {
      if(x[j] >= i){
        war = true;
        break;
      }
    }
    for (int j = 0; j < M; j++) {
      if(y[j] < i){
        war = true;
        break;
      }
    }
    if(war == false){
      cout << "No War" << endl;
      return 0;
    }
    war = false;
  }
  cout << "War" << endl;
  return 0;
}


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

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=998244353;

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

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}


const int N=200005;

void solve(){ 
	int N;
	cin>>N;
	while(N){
		if(N%10==7){
			cout<<"Yes";
			return;
		}
		N/=10;
	}
	cout<<"No";
	
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //~cin>>tc;
  for(int _=0;_<tc;_++){
    //~cout<<"Case #"<<_+1<<": \n";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



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

struct Node {
  int key;
  Node *parent;
  Node *left;
  Node *right;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;

  Node *z;
  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->parent = NIL;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

bool find(Node *root, int k) {
  Node *x = root;
  bool is_found = false;
  while (x != NIL) {
    if (k < x->key) {
      x = x->left;
    } else if (k > x->key) {
      x = x->right;
    } else {
      is_found = true;
      break;
    }
  }
  return is_found;
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

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

  for (int i = 0; i < n; i++) {
    string s;
    int k;
    cin >> s;
    if ( s == "insert") {
      cin >> k;
      insert(k);
    } else if (s == "print") {
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    } else if (s == "find") {
      cin >> k;
      if (find(root, k)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 21880
#include<bits/stdc++.h>
#define pb push_back
#define int long long 
#define pii pair<int,int>
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define ld long double
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
    fast;
    int n;
    cin>>n;
    int a[n+1];
    int xxor = 0;
    for(int i = 1;i<=n;i++){
        cin>>a[i];
        if(i<n)
            xxor^=a[i];
    }
    for(int i = 1;i<=n;i++){
        int ans = (a[i]^a[n])^(xxor);
        cout<<ans<<" ";
    }
}

Measured memory_bytes: 5132
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

# 相手の手がkeyだった時に勝つと得られるポイント
score = {"s":R,"p":S,"r":P}
# K手前が同じ手だったフラグ
flag = [False for i in range(N)]
ans = 0
for i in range(N):
    if (flag[i]):
        pass
    else:
        ans += score[T[i]]
        if (N-i-1 >= K):
            if (T[i] == T[i+K]):
                flag[i+K] = True

print(ans)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll n,ans;cin>>n;
    for(ll i=sqrt(n);i>0;i--){
        if(n%i==0){
            ans=i;
          break;
        }
    }
    ll k=n/ans;
    cout<<k+ans-2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


main(){
  ll h,ans=0;
  cin>>h;
  ll st=h;
  ll pos=1;
  ll cnt=-1;
  while(cnt!=0){
    if(st==0)break;
    else{
      st/=2;
      ans+=pos;
      pos*=2;
    }
  }
  cout<<ans;
}


/*
ll a[210000];
main(){
    ll n,k,ans=0;
    cin>>n>>k;
    ll s=0;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll st=k;
    rep(i,k,n)ans+=a[i];
    if(n<=k)cout<<0;
    else cout<<ans;
}*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[26];
void pd(string x){
	int l=x.size();
	int n[26];
	memset(n,0,sizeof(n));
	for(int i=0;i<l;i++)
		n[x[i]-'a']++;
	for(int i=0;i<26;i++)
		a[i]=min(n[i],a[i]);
	return;
}
int main(){
	int n;
	string x;
	cin>>n;
	memset(a,9999,sizeof(a));
	for(int i=1;i<=n;i++){
		cin>>x;
		pd(x);
	}
	for(int i=0;i<26;i++)
		for(int j=0;j<a[i];j++)
			cout<<char(i+'a');
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	ll a, b, k;
	cin >> a >> b >> k;
	if(a >= k)
	cout << a - k << ' ' << b;
	else
	cout << 0 << ' ' << max(0ll, b - (k - a)); 	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
int main() {
	string s;
	int w;
	cin >> s >> w;
	int count1 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (count1 == 0)cout << s[i];
		count1++;
		if (count1 == w)count1 = 0;
	}
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int i = (0);i < (n);++i)
#define rep(i,s,g) for(int i = (s);i < (g);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cerr << v[a][b] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	iv dv;
	iv tv;
	
	int n,m;
	cin >> n;
	
	REP(i,n)
	{
		int tmp;
		cin >> tmp;
		dv.PB(tmp);
	}
	
	cin >> m;
	REP(i,m)
	{
		int tmp;
		cin >> tmp;
		tv.PB(tmp);
	}
	
	sort(ALL(dv));
	sort(ALL(tv));
	
	//SHOW1d(dv,dv.size());
	//SHOW1d(tv,tv.size());
	
	
	int i = 0,j = 0;
	while(1)
	{
		if(i == tv.size())
		{
			cout << "YES" << endl;
			break;
		}
		if(j == dv.size())
		{
			cout << "NO" << endl;
			break;
		}
		
		while(tv[i] != dv[j])
		{
			if(j == dv.size())break;
			j++;
		}
		if(tv[i] == dv[j]){i++;j++;}
	}
	
	
	return 0;
}

Measured memory_bytes: 2548