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

#define int long long
#define pb push_back
#define F first
#define S second

signed main(){
    int N, W;
    cin>>N>>W;
    int K[N+1][W+1];
    int wt[N];
    int val[N];
    int a,b;
    for(int i=0; i<N; i++){
        cin>>a>>b;
        wt[i] = a;
        val[i] = b;
    }for (int i = 0; i <= N; i++) 
   { 
       for (int w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
    cout<<K[N][W]<<endl;
    return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  if(m==1){
    cout<<1<<" "<<2<<endl;
    return 0;
  }
  if(n%2==1){
    n--;
    int p=n/2;
    int q=p+1;
    for(int i=0;i<m;i++){
      cout<<p<<" "<<q<<endl;
      p--;
      q++;
    }
    return 0;
  }
  int p=n/2-1;
  int q=n/2+1;
  int r=n/2-2;
  int s=n/2+2;
  int a=0;
  int b=0;
  int vec[n+1];
  for(int i=0;i<n+1;i++){
    vec[i]=0;
  }
  for(int i=1;i<=m;i++){
    if(i%2==1){
      cout<<(i+1)/2<<" "<<n-(i+1)/2+1<<endl;
    }
    if(i%4==2){
      cout<<p<<" "<<q<<endl;
      p-=2;
      q+=2;
    }
    if(i%4==0){
      cout<<r<<" "<<s<<endl;
      r-=2;
      s+=2;
    }
  }
}

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

using namespace std;

int dp[510][510];

int main(){
	int n, m, q, x, y;
	cin >> n >> m >> q;
	for(int i = 1; i <= m; i++)
		cin >> x >> y, dp[x][y]++;
	for(int i = 1; i <= n; i++)
		for(int j = i; j <= n; j++)
			dp[i][j] += dp[i][j - 1];
	int l, r;
	while(q--){
		cin >> l >> r;
		int rs = 0;
		for(int i = l; i <= r; i++)
			rs += dp[i][r];
		cout << rs << '\n';
	}
	return 0;
}

Measured memory_bytes: 1920
import sys
import decimal

def input():
    return sys.stdin.readline().strip()

def main():
    a, b, c = map(int, input().split())
    ans = "No"
    if a == b and a != c:
        ans = "Yes"
    elif a == c and a != b:
        ans = "Yes"
    elif b == c and b != a:
        ans = "Yes"
    print(ans)
    
main()

Measured memory_bytes: 5076
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    int A1,A2,A3;

    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22)
    {
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }
    return 0;
}

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

using namespace std;

int n, k;
int MAX = 999999999;
vector<int> hi, memo;

int jump(int position)
{
  if (position > n)
    return MAX;
  if (position == n)
    return 0;
  if (memo[position] != -1)
    return memo[position];
  int left = MAX, right = MAX;

  left = abs(hi[position] - hi[position + 1]) + jump(position + 1);

  right = abs(hi[position] - hi[position + 2]) + jump(position + 2);
  if (left < 0)
    left = 0;
  if (right < 0)
    right = 0;
  memo[position] = min(left, right);
  return min(left, right);
}

int main()
{

  cin >> n;
  hi.resize(n + 1);
  memo.resize(n + 1, -1);
  for (int i = 0; i < n; i++)
    cin >> hi[i + 1];
  cout << jump(1) << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    while(a % 4 != 0){
        ans ^= a;
        a++;
    }
    while(b % 4 != 3 && b % 4 != -1){
        ans ^= b;
        b--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n = int(input().rstrip())
seconds = [int(input().rstrip()) for _ in range(n)]
#seconds = list(set(seconds))

def gcd(a,b):
    if int(b) == 0:
        return int(a)
    return gcd((b),(a%b))
def lcm(a,b):
    g = gcd(a,b)
    if a<b:
        return int(a/g)*b
    else:
        return int(b/g)*a

ans = 1
for num in seconds:
    ans = int(lcm(ans,num))
print(ans)

Measured memory_bytes: 3064
loop do
  n, k = gets.split.map(&:to_i)
  
  break if n == 0
  
  s = gets.split.map(&:to_i)
  
  n.times do
    b = gets.split.map(&:to_i)
    
    k.times do |i|
      s[i] -= b[i]
    end
  end
  
  puts s.all?{ |i| i >= 0 } ? "Yes" : "No"
end

Measured memory_bytes: 9136
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <math.h>

using namespace std;
typedef pair<int, int> pii;
typedef pair<int, long double> pild;
typedef pair<long double, int> pldi;

void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//最小公倍数
//O(log max(a,b))
template<class T>
T GCD(T a, T b) {
	if (b == 0)return a;
	return GCD(b, (T)(a%b));
}

//最大公約数(複数)
//O(nlog max(a_i))?
template<class T>
T GCD(vector<T> v) {
	for (int n = 1; n < v.size(); n++) {
		v[n] = GCD(v[n], v[n - 1]);
	}
	return v[v.size() - 1];
}

int N;
vector<int> arr;
vector<int> garr2;
vector<int> garr1;

void solve() {
	cin >> N;
	if (N == 2) {
		int a, b; 
		cin >> a >> b;
		cout << max(a, b) << endl;
		return;
	}
	arr.resize(N);
	garr1.resize(N);
	garr2.resize(N);
	for (int n = 0; n < N; n++)cin >> arr[n];
	sort(arr.begin(),arr.end());
	garr1[0] = arr[0];
	for (int n = 1; n < N; n++) {
		garr1[n] = GCD(garr1[n-1],arr[n]);
	}
	garr2[N - 1] = arr[N - 1];
	for (int n = N - 2; n >= 0; n--) {
		garr2[n] = GCD(garr2[n+1],arr[n]);
	}
	int m = max(garr2[1],garr1[N-2]);
	for (int n = 1; n < N-1; n++) {
		m = max(m,GCD(garr1[n-1],garr2[n+1]));
	}
	cout << m << endl;
	return;
}

Measured memory_bytes: 1408
N = int(input())


def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


ans = 0
for i in range(1, N + 1, 2):
    p = make_divisor_list(i)
    if len(p) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
bool qry(int x,int y) {
	cout << '?' << ' ' << x << ' ' << y << std::endl;
	static char s[4]; std::cin >> s;
	return *s == 'Y';
}
int a, b;
int st[maxn], top;
int main() {
	cin >> a >> b;
	if(a <= b) {
		cout << "Impossible" << '\n';
	} else {
		for(int i = 0;i < a + b;++i) {
			if(!top || qry(i, st[top])) {
				st[++top] = i;
			} else top && -- top;
		}
		std::string ans = "! ";
		rep(i, 0, a + b - 1) ans += "01"[qry(st[1], i)];
		cout << ans << '\n';
	}
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 300 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int n, d;
    cin >> n >> d;
    d = 2 * d + 1;
    int ans = (n + d - 1) / d;
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d",$n);

$keta = 0;
while ($n >= 10**($keta+1)) {
	$keta ++;
}
$k = 10**$keta;

if ($n % (10**$keta) === $k - 1) {
	echo calc($n);
	return;
}
echo calc($n - ($n % $k) -1);
return;

function calc(int $n) {
	$res = 0;
	while ($n) {
		$res += $n % 10;
		$n = ($n - ($n % 10)) / 10;
	}
	return $res;
}


Measured memory_bytes: 4728
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
ans = 0
for i in range(1, 100000):
    if i**2 > n:
        break
    ans = i**2

print(ans)


Measured memory_bytes: 2940
input()
a = [int(i) for i in input().split(" ")]

cont = 0
max_cont = 0

for n in a:
    if n == 1:
        cont += 1
    elif cont > max_cont:
        max_cont = cont
        cont = 0
    else:
        cont = 0

if cont > max_cont: max_cont = cont
print(max_cont+1)


Measured memory_bytes: 5604
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A,B,C=map(int,pin().split())
  if (A<C and C<B) or (B<C and C<A):
    print("Yes")
    return 
  print("No")
  return 

main()

Measured memory_bytes: 9116
s_in = str(input())
s = list(s_in)
ans = 0
rain = 0
for i in range(3):
    if s[i]== 'R':
        if rain == 1:
            ans += 1
        else:
            ans = 1
        rain = 1
    else:
        rain = 0
print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i16,
        b: i16
    }
    // A個口の電源タップを未使用の差込口に入れると、
    // 未使用の差込口が合計A-1個増える。
    let mut q = (b - 1) / (a - 1);
    let r = (b - 1) % (a - 1);
    if r > 0{
        q += 1;
    }
    println!("{}", q);
}


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

const int MAX_N = 20;

int main() {
  int N, H[MAX_N];
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> H[i];
  }

  int maxHeight = H[0], ans = 0;
  for(int i = 0; i < N; ++i) {
    if(maxHeight <= H[i]) ++ans;
    maxHeight = std::max(maxHeight, H[i]);
  }

  std::cout << ans << std::endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
int a[maxn];
ll dp[105][maxn];
ll sum[maxn];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sum[k]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(j==0) dp[i][j]=(dp[i][j]+sum[min(k,j+a[i])])%Mod;
            else dp[i][j]=(dp[i][j]+sum[min(k,j+a[i])]-sum[max(0,j-1)]+Mod)%Mod;
           // dbg3(i,j,dp[i][j]);
        }
        sum[0]=dp[i][0];
        for(int j=1;j<=k;j++) sum[j]=(sum[j-1]+dp[i][j])%Mod;
    }
    printf("%lld\n",dp[n][0]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 79360
N = int(input())
T = list(map(int,input().split()))
Total = sum(T)
M = int(input())
drinks = []
for _ in range(M):
  p,x = map(int,input().split())
  drinks.append([p,x])
for drink in drinks:
  Ans = Total -T[drink[0]-1] + drink[1]
  print(Ans)


Measured memory_bytes: 3060
//OM
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <sstream>
#include <algorithm>
using  namespace  std;

#define  x first
#define  y second
#define  pb push_back
#define  mp make_pair
#define  PI (acos(-1.0))
#define  mem(a,b) memset(a,b,sizeof(a))
#define  Sort(x) sort(x.begin(),x.end())
#define  FOR(i, b, e) for(int i = b; i <= (int)(e); i++)
#define  FORR(i, b, e) for(int i = b; i >=(int)(e); i--)
#define  FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define  pr(x) cout<<x<<"\n"
#define  prs(x) cout<<x<<" "
#define  pr2(x,y) cout<<x<<" "<<y<<"\n"
#define  pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define  ppr(a) cout<<a.x<<" "<<a.y<<"\n"
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

typedef  long long ll;
typedef  pair <int, int> pii;
typedef  pair <double, double> pdd;
typedef  vector <int> vi;
typedef  vector <pii> vpii;


//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 Direction

#define  EPS 1e-9
#define  MAX 100007
#define  MOD 1000000007

int main()
{
//    READ("in.txt");
//    WRITE("out.txt");
    int T,n;
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[3]==s[1]&&s[1]==s[2])){
        printf("Yes");
    }
    else printf("No");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    int n;cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        if(a%2==0)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3104
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)
C = [int(c) for c in input().split()]

C.sort(reverse=True)
M = sum(C) - C[0]

from collections import deque
q = deque([0])
ans = [0]*N
ans[0] = C[0]
i = 1
while q:
    u = q.popleft()
    for v in E[u]:
        if ans[v] > 0:
            continue
        ans[v] = C[i]
        i += 1
        q.append(v)

print(M)
print(*ans)

Measured memory_bytes: 6296
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
using namespace std;
typedef int gitype;
gitype gi () {
    gitype ret=0; char ch=getchar();
    while((ch<'0' || ch>'9') && ch!='-') ch=getchar();
    char c=ch=='-'?getchar():ch;
    while(c>='0' && c<='9') ret=ret*10+c-'0',c=getchar();
    return ch=='-'?-ret:ret;
}
const int N = 10010;
const int M = 100010;
int n,m,st[N],vis[N],dis[N],pt[M],nxt[M],w[M],c[M],cost[N],ent=0;
void link (int u,int v,int _w,int _c) {
    pt[++ent]=v; nxt[ent]=st[u]; st[u]=ent; w[ent]=_w; c[ent]=_c;
    pt[++ent]=u; nxt[ent]=st[v]; st[v]=ent; w[ent]=_w; c[ent]=_c;
}
queue<int> q;
int main () {
    while(scanf("%d%d",&n,&m)==2 && (n || m)) {
        memset(st,0,sizeof(st)); ent=0;
        int u,v,_w,_c;
        for(int i=1;i<=m;i+=1) {
            u=gi(); v=gi(); _w=gi(); _c=gi(); link(u,v,_w,_c);
        }
        for(int i=1;i<=n;i+=1) dis[i]=1e9 + 5;
        dis[1]=0; q.push(1);
        while(!q.empty()) {
            int r=q.front(); q.pop(); vis[r]=false;
            for(int i=st[r];i;i=nxt[i]) {
                if(dis[pt[i]] > dis[r]+w[i]) {
                    dis[pt[i]] = dis[r]+w[i]; cost[pt[i]] = c[i];
                    if(!vis[pt[i]]) {
                        vis[pt[i]] = true; q.push(pt[i]);
                    }
                } else if(dis[pt[i]] == dis[r]+w[i]) {
                    cost[pt[i]] = min(cost[pt[i]], c[i]);
                }
            }
        }
        int ans = 0;
        for(int i=2;i<=n;i+=1) ans += cost[i];
        printf("%d\n",ans);
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int Max = 0;
  int MaxIndex = 0;
  int Second = 0;
  for ( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    if ( Max < A.at(i) ){
      Max = A.at(i);
      MaxIndex = i;
    }
    else if ( Second < A.at(i) ){
      Second = A.at(i);
    }
  }

  for ( int i = 0; i < N; i++ ){
    if ( i != MaxIndex )
      cout << Max << endl;
    else
      cout << Second << endl;
  } 

}

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

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

        string s = sc.Next();

        string answer = "";

        for (int i = 0; i < s.Length; i++)
        {
            if (i % 2 == 0)
            {
                answer += s.Substring(i, 1);
            }
        }

        Console.WriteLine(answer);
    }

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

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

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

            return _line[_index++];
        }

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

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

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

Measured memory_bytes: 34772
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// beginning.rs --- Beginning
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        ns: [u32; 4],
    };

    let mut xs = ns;
    xs.sort();

    let ans = xs == [1, 4, 7, 9];
    println!("{}", if ans { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	string n;
	cin >> n;

	if((n[0]==n[1] && n[1]==n[2])||(n[1]==n[2] && n[2]==n[3])) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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


// dp[i][w] := i番目までの品物で重さがw以下となる選び方の価値の最大値
ll dp[101][101010];

int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N+1), v(N+1);

    rep(i, N) cin >> w[i+1] >> v[i+1];

    for (int i = 1; i <= N; ++i) {
        for (int j = W; j >= 0; --j) {
            if (j - w[i] >= 0) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }


    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
bool palin(int N){//Nが回文数かどうか
    string S = to_string(N);
    int M = (S.size()-1)/2 + 1;
    int n = S.size();
    bool flag = true;

    for(int i = M;i<n;i++){
        if(S[i] != S[n-i-1]) flag = false;
    }
   return flag;
}
/*
*/

int main() {
  int N;
  cin >> N;
  if(palin(N)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

P reflect(P a,P b,P c){
  b-=a;c-=a;
  return a+conj(c/b)*b;
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  scanf("%lf %lf %lf %lf %d",&ax,&ay,&bx,&by,&n);
  while(n--){
    scanf("%lf %lf",&cx,&cy);
    P p=reflect(P(ax,ay),P(bx,by),P(cx,cy));    
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}


Measured memory_bytes: 3216
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] list = new int[n][2];
		for (int i = 0; i < list.length; i++) {
			list[i][0] = sc.nextInt();
			list[i][1] = sc.nextInt();
		}
		
		double sum = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				sum += Math.sqrt(Math.pow((list[i][0] - list[j][0]), 2) + Math.pow((list[i][1] - list[j][1]), 2));
			}
		}
		
		System.out.println(sum / n * 2);
		
	}
}

Measured memory_bytes: 22868
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)
  
for rc in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

Measured memory_bytes: 7792
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdlib>
using namespace std;


int main(){
	string S;
	int counts = 0;
	bool coninued = true;
	cin >> S;
	
	// RSR -> 1
	// RRS -> 2
	// SRR -> 2
	// RRR -> 3
	// SRS -> 1
	for(int i=0; i<(int)S.size(); i++) {
		if(S[i] == 'R'){
			if(coninued){
				counts++;
			} else {
				counts = 1;
				coninued = true;
			}
		} else {
			coninued = false;
		}
	}
	cout << counts;
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 100000

int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return 2*i+1; }


int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int, int> a, pair<int, int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	string s;
	cin >> s;
	llint memo[6] = { 1,10,9,12,3,4 };
	vllint ans(13, 0);
	ans[0] = 1;
	drep(i, s.size()) {
		llint tmp = 0;
		if (s[i] == '?') {
			llint tmptmp[13];
			rep(j, 13) {
				tmptmp[j] = ans[j];
				ans[j] = 0;
			}
			rep(j, 10) {
				tmp = memo[(s.size() - i - 1) % 6] * j;
				tmp %= 13;
				rep(j, 13) {
					ans[(j + tmp) % 13] += tmptmp[j];
				}
			}
		}
		else {
			tmp += memo[(s.size() - i - 1) % 6] * (s[i] - '0');
			tmp %= 13;
			llint tmptmp[13];
			rep(j, 13) {
				tmptmp[j] = ans[j];
			}
			rep(j, 13) {
				ans[(j + tmp) % 13] = tmptmp[j];
			}
		}
		rep(j, 13) {
			ans[j] %= 1000000007;
		}
	}
	cout << ans[5] << endl;
	return 0;
}

Measured memory_bytes: 512
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
#include <string>
using namespace std;

int main(){
	string a, b;
	cin >> a >> b;

	if (a.length() > b.length()){
		cout << "GREATER" << endl;
	}
	else if (a.length() < b.length()){
		cout << "LESS" << endl;
	}
	else{
		for (int i = 0; i < a.length(); ++i){
			if (a[i] < b[i]){
				cout << "LESS" << endl;
				return 0;
			}
			else if (a[i] > b[i]){
				cout << "GREATER" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>




int main(){

  int b=100000,n;
  scanf("%d",&n);
 
  for(int i = 0;i<n;i++){
    b*=1.05;
    if(b%1000!=0)b=(b/1000+1)*1000;
  }

  printf("%d\n",b);

  return 0;
}

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

long long solve(long long N){
    if(N%2 == 1)return 0;
    
    long long ans = 0;
    N /= 2;
    
    while(N){
        ans += N/5;
        N /= 5;
    }
    
    return ans;

}


int main(){
    long long N; cin >> N;
    cout << solve(N) << endl;
}

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

const int INF=100000000;


int main() {
   int n,k,h[100000];
   cin>>n>>k;

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

   int sum=0;
   int ans=1000000000;
   for (int i = 0; i < n-k+1; ++i){
      sum=h[i+k-1]-h[i];
      ans=min(ans,sum);
   }

   cout<<ans<<endl;


}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    FIO;
    ll a;
    cin >> a;
    string s;
    cin >> s;
    if(a < 3200){
        cout << "red" << endl;
    }else{
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	string S;
	cin >> S;
	vector<int> cnt1(2019), cnt2(2019);
	ll ans = 0;

	for(int i=0; i<S.size(); i++){
		for(int j=0; j<2019; j++){
			cnt2[(10*j+S[i]-'0')%2019] = cnt1[j];
		}
		cnt2[S[i]-'0']++;
		ans += cnt2[0];
		cnt1=cnt2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>
#include<stack>

using namespace std;

typedef long long ll;

const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int MAX = 19;
int W, H, fld[10][10];
int P, sx, sy;
map<pair<pair<int, int>, int>, int> memo;

inline int CountBit(int s)
{
	int res = 0;
	for (int i = 0; i < P; i++) res += (s >> i) & 1;
	return res;
}

inline bool IsInside(int x, int y)
{
	return 0 <= x && x < W && 0 <= y && y < H;
}

inline bool CanDown(int x, int y, int s, int noBits)
{
	if (x == sx && y == sy && noBits == P) return true;
	if (fld[y][x] == -1) return false;
	return ((s >> fld[y][x]) & 1) == 0;
}

int DFS(int x, int y, int s, int &order)
{
	order++;
	int noBits = CountBit(s);
	if (x == sx && y == sy && noBits == P) return 1;
	pair<pair<int, int>, int> state = make_pair(make_pair(x, y), s);
	if (noBits < MAX)
	{
		map<pair<pair<int, int>, int>, int>::iterator itr = memo.find(state);
		if (itr != memo.end()) return itr->second;
	}
	int sum = 0, cnt = 0;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		while (IsInside(nx, ny) && !CanDown(nx, ny, s, noBits))
			nx += dx[i], ny += dy[i];
		if (!IsInside(nx, ny)) continue;
		sum += DFS(nx, ny, s | (1 << fld[ny][nx]), cnt);
	}
	order += cnt;
	if (noBits < MAX && !(noBits >= 16 && cnt <= 10)) memo[state] = sum;
	return sum;
}

signed main()
{
	while (cin >> W >> H, W || H)
	{
		memo.clear();
		P = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> fld[i][j];
				if (fld[i][j] == 0) fld[i][j] = -1;
				else if (fld[i][j] == 1) fld[i][j] = P++;
				else sx = j, sy = i, fld[i][j] = -1;
			}
		}
		int cnt = 0;
		printf("%d\n", DFS(sx, sy, 0, cnt));
	}
	return 0;
}

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

using namespace std;

// Prioridade
typedef long long   ll;
typedef pair<ll,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))

// fim da Prioridade
int dp[110][100010];
int n;
int v[110];
int w[110];


int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n ;
	int valor = 0;
	cin >> valor;
	REP(i,1,n+1){
		cin >> w[i] >> v[i];
	}
	memset(dp,-1,sizeof dp);
	dp[0][0] = valor;
	int ans = 0;
	REP(i,1,n+1){
		REP(j,0,100010){
			if(j - v[i] >= 0 ){
				dp[i][j] = max(dp[i-1][j-v[i]] - w[i],dp[i-1][j]);
				if(dp[i][j] >= 0)
					ans = max(j,ans);
			}else{
				dp[i][j] = max(dp[i][j],dp[i-1][j]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 43264
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
vector<unsigned int> a,b;
unsigned int n,c;
unsigned int memo[30][1<<16];
unsigned int dp(int p,const unsigned int now)
{
	if(p==n)return 0;
	if(memo[p][now]!=999999)return memo[p][now];
	unsigned int next =now|a[p];
	unsigned int ans=0;
	for(int i=0;i<c;i++)
	{
		unsigned int k=b[i]&next;
		unsigned int tans=0;
		unsigned int h=1;
		unsigned int f=0;
		for(int l=0;l<16;l++)
		{
			if(k&h)
			{
				tans++;
			}
			h<<=1;
		}
		
		k =b[i];
		h=1;
		for(int l=0;l<16;l++)
		{
			
			if((next&h)&&(k&h)==0)
			{
				f|=h;
			}
			h<<=1;
		}
		tans+=dp(p+1,f);
		ans=max(ans,tans);
	}
	return memo[p][now]=ans;
	
}

int main()
{
	
	while(cin>>n>>c&&n)
	{
		for(int i=0;i<30;i++)for(int l=0;l<1<<16;l++)memo[i][l]=999999;
		a.clear();
		b.clear();
		for(int i=0;i<n;i++)
		{
			unsigned int x=0;
			for(int l=0;l<16;l++)
			{
				unsigned int j;cin>>j;
				x<<=1;
				x|=j;
			}
			a.push_back(x);
		}
		for(int i=0;i<c;i++)
		{
			unsigned int x=0;
			for(int l=0;l<16;l++)
			{
				unsigned int j;cin>>j;
				x<<=1;
				x|=j;
			}
			b.push_back(x);
		}
		cout<<dp(0,0)<<endl;
		
	}
}

Measured memory_bytes: 8892
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
   static long i,j,k;
   long n;
   long cnt = 0;
   long left,right,mid;
   long ans = 0;
   int a,b;
   static long e[10000];
   char op;
   long long sum = 0;
   long max = -1000000,min = 10000000;
   scanf("%ld",&n);

   for(i = 0; i < n; i++) {
      scanf("%ld",&e[i]);
      if(max < e[i])
         max = e[i];
      if(min > e[i])
         min = e[i];
      sum += e[i];
   }
   printf("%ld %ld %lld\n",min,max,sum);
   return 0;
}

Measured memory_bytes: 1104
def LCS(s1,s2):
    l1, l2 = len(s1), len(s2)
    if l1 == 0 or l2 == 0:
        return ''
    
    dp = [[0 for i in range(l2+1)] for j in range(l1+1)]

    for i in range(l1):
        for j in range(l2):
            if s1[i] == s2[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            dp[i+1][j+1] = max(max(dp[i+1][j+1],dp[i][j+1]),dp[i+1][j])
    
    lcs_str = ''
    i,j = l1,l2
    while i>0 and j>0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        else:
            lcs_str += s[i-1]
            i -= 1
            j -= 1
    
    return lcs_str[::-1]

s = input()
t = input()
print(LCS(s,t))

Measured memory_bytes: 147324
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    vector<ll>h(n);
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(k<=0){
            ans+=h[i];
        }
        else k--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,flag;
int main()
{
    //IOS;
    cin>>n;
    while(1)
    {
        if(n==0)
        {
            break;
        }
        if(n%10==7)
        {
            flag=1;
            break;
        }
        n/=10;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long int x;
	scanf("%lld",&x);
	long long int l=1,r=x,mid,s,x1;
	while(l<=r)
	{
		mid=(r-l)/2+l;
		if(mid*(mid+1)/2<x) l=mid+1;
		else r=mid-1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> cost(n, 0);
  vector<vector<int>> a(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  ll ans = INF;
  for (int i = 0; i < (1 << n); i++) {
    ll c = 0;
    vector<int> skill(m, 0);
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        c += cost[j];
        for (int k = 0; k < m; k++) {
          skill[k] += a[j][k];
        }
      }
    }
    bool ok = true;
    for (auto j : skill) {
      if (j < x)
        ok = false;
    }
    if (ok) {
      chmin(ans, c);
    }
  }
  if (ans == INF)
    ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<numeric>
#include<map>

#define MAX 1000

using namespace std;

typedef pair<int,int> P;
P score[100001],par[100001];

int main(){
	int n,m,h,k;
	while(scanf("%d%d%d%d",&n,&m,&h,&k)){
		if(n==0&&m==0&&h==0&&k==0)
		break;
		vector<P> v;
		int p[MAX+1],s[MAX+1];
		
		for(int i=0;i<n;i++){
			s[i]=i;
			scanf("%d",&p[i]);
		}
		for(int i=0;i<m;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			v.push_back(make_pair(b,a-1));
		}
		sort(v.begin(),v.end());
		for(int i=0;i<m;i++){
			int a,b;
			int j=m-i-1;
			par[i].first=s[v[i].second];
			par[i].second=s[v[i].second+1];
			swap(s[v[i].second],s[v[i].second+1]);
			score[j].first=p[v[j].second];
			score[j].second=p[v[j].second+1];
			swap(p[v[j].second],p[v[j].second+1]);
		}
		int sum=accumulate(p,p+k,0);
		int ans=sum;
		for(int i=0;i<m;i++){
			if(par[i].first<k&&par[i].second>=k){
				ans=min(sum-(score[i].second-score[i].first),ans);
			}
		}
		printf("%d\n",ans);
	}
}

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

long long m, n;
vector<long long> s;

long long solve();
long long calc(long long x);

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    s.resize(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  if(calc(1) < m && calc(1) >= 0) return -1;
  long long l = 1, r = 1e18;
  while(r - l > 1) {
    long long mid = (l + r) / 2, res;
    res = calc(mid);
    if(res < 0 || res >= m)
      l = mid;
    else
      r = mid;
  }
  if(calc(l) >= m)
    return l;
  else
    return -1;
}

long long calc(long long x) {
  if(1 + x <= s[0]) return -1;
  long long res = 0, now = 1;
  while(++res < m) {
    if(now + x > s[n - 1]) break;
    auto it = lower_bound(s.begin(), s.end(), now);
    long long tmp = -1;
    if(now + x > *(it)) tmp = *it;
    if(it != s.begin()) {
      --it;
      if(abs(now - tmp) > abs(now - *(it))) tmp = *it;
    }
    now += max(1LL, x - abs(now - tmp));
  }
  return res;
}


Measured memory_bytes: 4108
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

bool aiu(char ch) {
    return ch == 'a' || ch == 'i' || ch == 'u' || ch == 'e' || ch == 'o';
}

vector<string> parse(const string& s) {
    vector<string> v;
    int pos = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (aiu(s[i]) || s[i] == 'n' || s[i] == '\'') {
            if (pos != i) v.push_back(s.substr(pos, i-pos));
            v.push_back(s.substr(i, 1));
            pos = i+1;
        }
    }
    if (pos < (int)s.size()) v.push_back(s.substr(pos));
    return v;
}

bool musei(const string& s) {
    char c = s[0];
    return c == 'k' || c == 's' || c == 't' || c == 'h' || c == 'p';
}

bool hatsu(const string& s) {
    return s.size() >= 2 && s[0] == s[1];
}

bool rule1(const vector<string>& ns, int ix) {
    if (ns[ix] != "i" && ns[ix] != "u") return false;
    return ix > 0 && musei(ns[ix-1]) &&
        (ix == (int)ns.size()-1 || musei(ns[ix+1]));
}

bool rule2(const vector<string>& ns, int ix) {
    if (ns[ix] != "a" && ns[ix] != "o" && ns[ix] != "u") return false;
    if (ix + 2 >= (int)ns.size()) return false;
    if (ns[ix] != ns[ix+2]) return false;
    return ix > 0 && musei(ns[ix-1]) && musei(ns[ix+1]) && !hatsu(ns[ix+1]);
}

int main() {
    for (;;) {
        string s;
        cin >> s;
        if (s == "#") return 0;
        vector<string> ns = parse(s);
        const int n = ns.size();
        vector<bool> is(n);
        rep (i, n) if (aiu(ns[i][0])) {
            if (rule1(ns, i)) is[i] = true;
            if (rule2(ns, i)) is[i] = true;
        }
        bool pre = false;
        rep (i, n) if (aiu(ns[i][0])) {
            if (pre) is[i] = false;
            pre = is[i];
        }
        rep (i, n) {
            if (is[i]) printf("(%s)", ns[i].c_str());
            else printf("%s", ns[i].c_str());
        }
        printf("\n");
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int n = in();
  int cnt = 0;
  rep(i,n) if(i+1!=in()) cnt++;
  if (cnt == 2 || cnt == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
//  ll s = in();
//  ll x1 = 1e9, x2 = 1;
//  ll y2 = dup(s,x1), y1 = x1*y2-s;
//  vl ans;
//  ans.pb(0); ans.pb(0);
//  ans.pb(x1); ans.pb(y1);
//  ans.pb(x2); ans.pb(y2);
//  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256