akhauriyash/Code-Regression huggingface dataset:
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

// reference: https://codeforces.com/blog/entry/64250?#comment-482588

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=17;

int mat[N][N];
vi tmp;

int calc(int mask)
{
    tmp.clear();
    for(int j=0;mask;mask>>=1,++j)
    {
        if(mask&1)
            tmp.pb(j);
    }

    int len=sz(tmp);
    int res=0;
    for(int i=0;i<len;++i)
    {
        for(int j=i+1;j<len;++j)
            res+=mat[tmp[i]][tmp[j]];
    }

    return res;
}

void solve()
{
    int n;
    cin>>n;

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

    int tot=(1<<n);
    int dp[tot],cost[tot];
    mem(dp,0);
    mem(cost,0);

    for(int mask=1;mask<tot;++mask)
        cost[mask]=calc(mask);

    for(int mask=1;mask<tot;++mask)
    {
        for(int sub=mask;sub;sub=(sub-1)&mask)
        {
            if(sub==mask)
                dp[mask]=cost[mask];
            else
                dp[mask]=max(dp[mask],dp[sub]+cost[mask^sub]);
        }
    }

    cout<<dp[(1<<n)-1];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int &a:A)
        cin >> a;
    vector<vector<ll>> dp(N+1, vector<ll>(2));
    dp[0][1] = -INF;

    for(int i=0; i<N; i++){
        dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]-A[i]);
        dp[i+1][1] = max(dp[i][0]-A[i], dp[i][1]+A[i]);
    }
    
    cout << dp[N][0] << endl;
    return 0;
}


Measured memory_bytes: 6144
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int Cube[30];
bool Check(){
    for(int i=0;i<30;i++){
        int s;
        if(i>=21)s=3;
        else if(i>=18)s=5;
        else if(i>=15)s=6;
        else if(i>=12)s=4;
        else if(i>=9)s=2;
        else s=1;
        if(Cube[i]!=s)return false;
    }
    return true;
}
void Swap(int *Order){
    for(int i=0;i<5;i++){
        swap(Cube[Order[i*2]],Cube[Order[i*2+1]]);
    }
}
void Right(){
    int o[10]={2,21,8,27,5,24,12,14,11,18};
    Swap(o);
}
void Left(){
    int o[10]={0,23,6,29,3,26,9,20,15,17};
    Swap(o);
}
void Back(){
    int o[10]={0,27,2,29,1,28,14,15,18,20};
    Swap(o);
}
void Front(){
    int o[10]={6,21,8,23,7,22,9,11,12,17};
    Swap(o);
}
int dfs(int pos){
    if(Check())return pos;
    if(pos>=8)return 100;
    int mi=100;
    Right();mi=min(mi,dfs(pos+1));Right();
    Left();mi=min(mi,dfs(pos+1));Left();
    Front();mi=min(mi,dfs(pos+1));Front();
    Back();mi=min(mi,dfs(pos+1));Back();
    return mi;
}
int main(){
    int n;
    cin>>n;
    while(n--){
        for(int i=0;i<30;i++)cin>>Cube[i];
        cout<<dfs(0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())

for i in range(N):
    b = int(input())
    if b in A[0]:
        A[0][A[0].index(b)] = 0
    elif b in A[1]:
        A[1][A[1].index(b)] = 0
    elif b in A[2]:
        A[2][A[2].index(b)] = 0

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2]:
        print('Yes')
        sys.exit()
    elif A[0][i] == A[1][i] == A[2][i]:
        print('Yes')
        sys.exit()

if A[0][0] == A[1][1] == A[2][2]:
    print('Yes')
    sys.exit()
elif A[0][2] == A[1][1] == A[2][0]:
    print('Yes')
    sys.exit()
else:
    print('No')


Measured memory_bytes: 9152
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int length = str.length();
    str = str.replace("0", "");
    int length0 = length - str.length();
    int length1 = str.length();
    System.out.println(Math.min(length0, length1) * 2);
  }
}

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

#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forse(i,s,e) for(int i=(int)s;i<(int)e;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using dbl=double;
using ll=long long;
using pii=pair<int, int>;
using pll=pair<ll, ll>;

dbl PI=3.141592653589793;


void solve(){
	int n,k;
	cin >> n >> k;
	vector<int> tem(n);
	forn(i,n){
		cin >> tem[i];
	}
	sort(all(tem));
	int out=0;
	forn(i,k){
		out+=tem[i];
	}
	cout << out;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	for(int c=1;c<=T;c++){
		solve();
	}
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int a[10005];


int main()
{
    int d,n;
    cin>>d>>n;
    if(d==0)
    {
        if(n!=100)
            cout<<n<<endl;
        else
            cout<<"101"<<endl;
    }
   if(d==1)
    {
        if(n!=100)
            cout<<n*100<<endl;
        else
            cout<<"10100"<<endl;
    }
     if(d==2)
    {
        if(n!=100)
            cout<<n*10000<<endl;
        else
            cout<<"1010000"<<endl;
    }



    return 0;
}


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

int N, M, K;
int fa[MAXN] = {0}, ans[MAXN] = {0}, siz[MAXN] = {0}, rk[MAXN] = {0};

int find (int x) {
    fa[x] = (fa[x] == x ? x : find (fa[x]));
    return fa[x];
}

void uni (int x, int y) {
    int u = find (x);
    int v = find (y);
    if (rk[u] >= rk[v]) {
        fa[v] = u;
        if (u != v) siz[u] += siz[v];
        if (rk[u] == rk[v]) rk[u] ++;
    }
    else {
        fa[u] = v;
        if (u != v) siz[v] += siz[u];
    }
}

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

    for (int i = 1; i <= N; i ++) {
        fa[i] = i;
        siz[i] = 1;
    }

    for (int i = 1; i <= M; i ++) {
        int a, b; cin >> a >> b;
        uni (a, b);
        ans[a] --;
        ans[b] --;
    }
    
    for (int i = 1; i <= N; i ++)
        ans[i] += siz[find (i)];

    for (int i = 1; i <= K; i ++) {
        int c, d; cin >> c >> d;
        if (find (c) == find (d)) {
            ans[c] --;
            ans[d] --;
        }
    }

    for (int i = 1; i <= N; i ++)
        cout << ans[i] - 1 << " ";
    
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h+1,vector<char>(w+1,'#'));
  vector<vector<LL>> dp(h+1,vector<LL>(w+1,0));
  dp[0][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> a[i][j];
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(a[i][j]=='.'){
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      }
    }
  }
  cout << dp[h][w] << endl;
  return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){
    vector<int> n(3);
    cin >> n.at(0) >> n.at(1) >> n.at(2);
    
    sort(n.begin(),n.end());
    
    cout << n.at(0) << " " << n.at(1) << " " << n.at(2) << endl;
}


Measured memory_bytes: 3148
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14
#define FALSE -1
char H[M][L]; 

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key)
{
  return key%M;
    }
int h2(int key)
{
  return 1+(key%(M-1));
    }

int find(char str[]){
  long long key,i,a;
  key=getKey(str);
  for(i=0; ;i++)
    {
      a=(h1(key)+i*h2(key))%M;
      if(strcmp(H[a],str)==0)
        {
          return 1;
        }
      else if(strlen(H[a])==0)
        {
          return 0;
        }
        }
      return 0;
}

int insert(char str[]){
  long long key,i,a;
  key=getKey(str);
  for(i=0; ;i++)
    {
      a=(h1(key)+i*h2(key))%M;
      if(strcmp(H[a],str)==0)
        {
          return 1;
        }
      else if(strlen(H[a])==0)
        {
          strcpy(H[a],str);
          return 0;
                }

    }
      return 0;
      
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 15460
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line: Vec<i128> = read_as_vec();
    let (x, k, d) = (line[0].abs(), line[1], line[2]);

    if x.abs() >= k * d {
        println!("{}", (x.abs() - k * d).abs());
        return;
    }

    let k = k - x / d;
    let x = x - (x / d) * d;
    if k % 2 == 0 {
        println!("{}", x);
    } else {
        println!("{}", (x - d).abs());
    }
}


Measured memory_bytes: 2112
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		boolean flag = true;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.parallelSort(a);;
		for(int i = 0; i < n-1; i++) {
			if(a[i]==a[i+1]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 64752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;cin >> n;
  vvl g(n,vl(n));rep(i,n)rep(j,n)cin >> g[i][j];
  vl sum(1<<n);
  rep(bit,1<<n){
    ll ret=0;
    rep(i,n)rep(j,n)if((bit&(1<<i))&&(bit&(1<<j)))ret+=g[i][j];
    sum[bit]=ret/2;
  }
  rep(bit,1<<n){
    per(cit,bit+1){
      cit&=bit;
      if(bit-cit>cit)break;
      chmax(sum[bit],sum[cit]+sum[bit-cit]);
    }
  }
  cout << sum[(1<<n)-1] <<endl;
}

Measured memory_bytes: 3728
#include <stdio.h>
int cnt[105],tot;
int main(){	
 	int n,k,m,i,j,a;	
  	scanf("%d%d",&n,&k);	
  	for(i=1;i<=k;i++){		
    	scanf("%d",&m);		
      	for(j=1;j<=m;j++){			
          	scanf("%d",&a);			
          	cnt[a]++;//记录拥有Snack的Snuke		
        }	
    }		
  	for(i=1;i<=n;i++) if(cnt[i])tot++;//统计拥有的Snack的Snuke数量	
  	printf("%d\n",n-tot);//输出没有拥有的Snack的Snuke数量	
  	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int n,c;
int mx=0;
int ti[35][200000];

int cnt(int nn){
  int ct=0;
  for(int i=1;i<=c;i++)
    if(ti[i][nn]>0) ct++;
  return ct;
}

int main(){

  cin>>n>>c;
  int s,t,cc,tp;
  for(int i=1;i<=c;i++)
    for(int j=1;j<200001;j++)
      ti[i][j]=0;
  for(int i=0;i<n;i++){
    cin>>s>>t>>cc;
    ti[cc][s*2-1]=1;
    ti[cc][t*2]=-1;
  }
  for(int i=1;i<=c;i++)
    for(int j=1;j<200001;j++)
      ti[i][j]+=ti[i][j-1];
  for(int i=1;i<200001;i++){
    tp=cnt(i);
    if(mx<=tp)mx=tp;
  }
  cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 24064
#include<iostream>
using namespace std;
int NIL=-1;

struct Node{
    int p=NIL,l=NIL,r=NIL;
};
int get_root(Node A[],int n){
    for(int i=0;i<n;i++){
        if(A[i].p==NIL)return i;
    }
}
void Preorder(Node A[],int id){
    if(id!=NIL){
    cout<<" "<<id;
    Preorder(A,A[id].l);
    Preorder(A,A[id].r);
    }
}
void Inorder(Node A[],int id){
    if(id!=NIL){
    Inorder(A,A[id].l);
    cout<<" "<<id;
    Inorder(A,A[id].r);
    }
}
void Postorder(Node A[],int id){
    if(id!=NIL){
    Postorder(A,A[id].l);
    Postorder(A,A[id].r);
    cout<<" "<<id;
    }
}

int main(){
    int n;cin>>n;Node A[n];
    for(int i=0;i<n;i++){
        int id;cin>>id;
        cin>>A[id].l>>A[id].r;
        if(A[id].l!=NIL)A[A[id].l].p=id;
        if(A[id].r!=NIL)A[A[id].r].p=id;
    }
    cout<<"Preorder"<<endl;
    Preorder(A,get_root(A,n));
    cout<<endl;
    cout<<"Inorder"<<endl;
    Inorder(A,get_root(A,n));
    cout<<endl;
    cout<<"Postorder"<<endl;
    Postorder(A,get_root(A,n));
    cout<<endl;
    return 0;
}


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

using namespace std;


int main(){
  string ring;
  string key;

  cin >> ring >> key;

  if(ring.find(key) == string::npos){
    // リング状にすれば見つかるかもしれない
    if(key.length() == 1){
      cout << "No" << endl;
      return 0;
    }
    string::size_type j = 0;
    for(string::size_type i = ring.length() - key.length() + 1; i < ring.size(); i++){
      if(ring[i] == key[0]){
        // cout << i << endl;
        // return 0;
        j = 0;
        string::size_type k = i;
        while(1){
          if(++k == ring.length())
            k = 0;

          if(ring[k] != key[++j]){
            break;
          } 

          if(j == key.length() -1){
            cout << "Yes" << endl;
            return 0;
          }
        }
      }
      if(i == ring.length() - 1){
        cout << "No" << endl;
      }
    }
    // ring[ring.length() - key.length() + 1];
  }else{
    // リング状でなくとも見つかるとき
    cout << "Yes" << endl;
  }

 

  return 0;
}



Measured memory_bytes: 3200
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int d;
    cin >> d;
    cout << "Christmas";
    for (int i = 0; i < 25 - d; i++)
    {
        cout << " Eve";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream> 
using namespace std; 
int main(void){ int i, n, a[100];
cin >> n; for (i=0;i<n;i++) cin >> a[i];
for (i=n-1; i>=0; i--){ if(i<n-1) cout << " "; cout << a[i];
} 
cout << endl;
return 0;

    
} 


Measured memory_bytes: 3080
n = gets.to_s.to_i
S = Array.new(n){ gets.to_s.to_i }

h = Hash.new(0)
h[0] = 0
sum_z = 0

S.each do |s|
  
  if 0 == s % 10
    sum_z += s
  else
    d = h.dup
    h.each{ |k,v| d[(s+k)%10] = [d[(s+k)%10], v + s].max }
    h = d.dup
  end
end

t = h.values.drop(1).max

puts t.nil? ? 0 : sum_z + t

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

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


int main(){
    int D,T,S;
    cin >> D >> T >>S;
    if(D<=T*S) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	int N, maxValue, minValue;
	cin >> N;

	string S, sortS;
	REP(i, N) {
		cin >> S; 

		SORT(S); sortS = S;
		DESCSORT(S);
		int max = stoi(S), min = stoi(sortS);

		cout << max - min << "\n";
	}
	return 0;
}

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

int n;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t;
	// cin>>t;
	// while(t--) {

	// }

	// cin>>n;
	int a, b, c, d, e;
	cin>>a>>b>>c>>d>>e;
	if(a == 0) cout<<"1\n";
	else if(b == 0) cout<<"2\n";
	else if(c == 0) cout<<"3\n";
	else if(d == 0) cout<<"4\n";
	else cout<<"5\n";

	
}




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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (ll i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  vector<ll> runrun;
  queue<ll> que;
  FOR(i, 1, 9) {
    runrun.push_back(i);
    que.push(i);
  }

  int cnt = 9;
  while (!que.empty() && cnt < 100010) {
    ll num = que.front();
    que.pop();
    ll last = num % 10;
    if (last - 1 >= 0) {
      runrun.push_back(num * 10 + last - 1);
      que.push(num * 10 + last - 1);
      cnt++;
    }
    runrun.push_back(num * 10 + last);
    que.push(num * 10 + last);
    cnt++;

    if (last + 1 < 10) {
      runrun.push_back(num * 10 + last + 1);
      que.push(num * 10 + last + 1);
      cnt++;
    }
  }

  ANS(runrun[k - 1]);

  return 0;
}


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

void solve(){
    int h,w;
    cin >> h >> w;
    char v[h+10][w+10]; //i行j列の要素
    rep(i,h){
        string str;
        cin >> str;
        rep(j,w){
            v[i][j] = str[j];
        }
    }
    //L[i][j]:i行j列に明かりを置いた時、そこから左方向に照らされるマスの数
    int L[h+10][w+10];
    rep(i,h){
        rep(j,w){
            if(v[i][j]=='#') L[i][j]=0;
            else if(j==0) L[i][j]=1;
            else L[i][j]=L[i][j-1]+1;
        }
    }
    //R[i][j]:i行j列に明かりを置いた時、そこから右方向に照らされるマスの数
    int R[h+10][w+10];
    rep(i,h){
        for(int j=w-1; j>=0; j--){
            if(v[i][j]=='#') R[i][j]=0;
            else if(j==w-1) R[i][j]=1;
            else R[i][j]=R[i][j+1]+1;
        }
    }
    //D[i][j]:i行j列に明かりを置いた時、そこから下方向に照らされるマスの数
    int D[h+10][w+10];
    rep(j,w){
        rep(i,h){
            if(v[i][j]=='#') D[i][j]=0;
            else if(i==0) D[i][j]=1;
            else D[i][j]=D[i-1][j]+1;
        }
    }
    //U[i][j]:i行j列に明かりを置いた時、そこから上方向に照らされるマスの数
    int U[h+10][w+10];
    rep(j,w){
        for(int i=h-1; i>=0; i--){
            if(v[i][j]=='#') U[i][j]=0;
            else if(i==h-1) U[i][j]=1;
            else U[i][j]=U[i+1][j]+1;
        }
    }

    /*
    テスト用
    rep(i,h){
        rep(j,w){
            cout << U[i][j];
        }
        cout << endl;
    }
    */

    int m=0;
    rep(i,h){
        rep(j,w){
            int tmp = L[i][j]+R[i][j]+D[i][j]+U[i][j]-3;
            m = max(m,tmp);
        }
    }
    cout << m << endl;
}

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

Measured memory_bytes: 67072
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ldb n, m, d; cin >> n >> m >> d;

	if (d == 0) printf("%.10Lf\n", (m - 1) / n);
	else printf("%.10Lf\n", (m - 1) * (2 * (n - d)) / (n * n));	
}


Measured memory_bytes: 3788
import heapq as hq

n = int(input())
a = [int(_) for _ in input().split()]

a.sort()
p = a.pop()
q = []
hq.heappush(q, (-p, -p))
ans = 0
for _ in range(n - 1):
    p = a.pop()
    b1, b2 = hq.heappop(q)
    ans += -b1
    hq.heappush(q, sorted((b1, -p), reverse=True))
    hq.heappush(q, sorted((b2, -p), reverse=True))
print(ans)


Measured memory_bytes: 47728
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007


int main(){
  int n,m;
  cin >> n >> m;
  int a[2000]={0},b[2000]={0};
  map<int,int>mpa,mpb;
  bool flag=true;
  rep(i,n){
    cin >> a[i];
    if(mpa.find(a[i])==mpa.end())mpa[a[i]]=0;
    mpa[a[i]]++;
    if(mpa[a[i]]>1)flag=false;
  }
  rep(i,m){
    cin >> b[i];
    if(mpb.find(b[i])==mpb.end())mpb[b[i]]=0;
    mpb[b[i]]++;
    if(mpb[b[i]]>2)flag=false;
  }
  sort(a,a+n,greater<int>());
  sort(b,b+m,greater<int>());
  ll ans=0;
  if(!flag){
    ans=0;
    //cout << "その入力は悪手" << endl;
  }
  ll res=1;
  ll counter=0,ca=0,cb=0;
  if(flag){
    for(int i=n*m;i>=1;i--){
      if(mpa.find(i)!=mpa.end()&&mpb.find(i)!=mpb.end()){
        //iがa,bの両方に含まれる時
        //no action
      }else if(mpa.find(i)!=mpa.end()){
        for(int j=0;b[j]>=i;j++){
          counter++;
        }
        res*=counter;
        res%=mod;
        counter=0;
      }else if(mpb.find(i)!=mpb.end()){
        for(int j=0;a[j]>=i;j++){
          counter++;
        }
        res*=counter;
        res%=mod;
        counter=0;
      }else{
        //neither exist
        for(int j=0;a[j]>=i;j++){
          ca++;
        }
        for(int k=0;b[k]>=i;k++){
          cb++;
        }
        counter=ca*cb;
        res*=counter-(n*m-i);
        res%=mod;
        counter=ca=cb=0;
      }
    }
    ans=res;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  int max_of=0;
  int sum=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    max_of=max(max_of,x);
    sum+=x;
  }
  if(max_of<sum-max_of){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i

ok = [a, b, c, d, e]
       .combination(2)
       .map { |p, q| q - p }
       .all? { |d| d <= k }
puts ok ? 'Yay!' : ':('


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main (void) {
	int n, k; cin >> n >> k;
	vector < pair <int, int> > occurency(n+1);
	for (int i = 0; i <= n; i++) {
		occurency[i].second = i;
		occurency[i].first = 0;
	}
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		occurency[a].first++;
	}
	//count # different elements we have
	int different = 0;
	for (int i = 1; i <= n; i++) {
		if (occurency[i].first != 0)
			different++;
	}
	
	int result = 0;
	if (different > k) {
		int to_change = different - k;
		sort(occurency.begin(), occurency.end());
		int j = 0;
		int changed = 0;
		while (changed < to_change && j <= n) {
			if (occurency[j].first != 0) {
				result += occurency[j].first;
				changed++;
			}
			j++;
			
		}
	}
	cout << result << endl;


	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	//?????°?§?????????????
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	//x????????????????????????????????£?????´???
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		//printf("delete first is called\n");
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	//?????????tmpNode != motherNode????????§??????????????\
	};

	void deleteLast(){
		//printf("delete last is called\n");
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; //?????????tmpNode != motherNode????????§??????????????\
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

	for(int i = 0; i < n; i++){

		buf[0] = '\0';
		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			//??????????¢??????????????????????
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	//delete x
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}

Measured memory_bytes: 32404
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    String S = scan.next();
    scan.close();

    long countR = 0;
    long countG = 0;
    long countB = 0;
    for(int i=0; i<N; i++) {
      if(S.charAt(i) == 'R') {
        countR++;
      }
      if(S.charAt(i) == 'G') {
        countG++;
      }
      if(S.charAt(i) == 'B') {
        countB++;
      }
    }

    long countNG = 0;
    for(int i=0; i<N-2; i++) {
      int interval = 1;
      while(i+2*interval < N) {
        if(S.charAt(i) != S.charAt(i+interval) && S.charAt(i) != S.charAt(i+2*interval) && S.charAt(i+interval) != S.charAt(i+2*interval)) {
          countNG++;
        }
        interval++;
      }
    }

    System.out.println(countR * countG * countB - countNG);
  }
}

Measured memory_bytes: 27632
#include <iostream>

void trace(int* arr, int& size) {
  for (int i = 0; i < size; i++) {
    std::cout << arr[i];
    std::cout << (i == size - 1 ? '\n' : ' ');
  }
}

void swap(int* arr, int& a, int& b) {
  int buf = arr[a];
  arr[a] = arr[b];
  arr[b] = buf;
}

int selectionSort(int* arr, int& size) {
  int swp = 0;
  for (int i = 0; i < size; i++) {
    int min = i;
    for (int j = i; j < size; j++) {
      if (arr[j] < arr[min]) min = j;
    }
    if (i != min) {
      swap(arr, i, min);
      swp++;
    }
  }
  return swp;
}

int main() {
  int n;
  std::cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    std::cin >> arr[i];
  }
  int swp = selectionSort(arr, n);
  trace(arr, n);
  std::cout << swp << std::endl;
  return 0;
}



Measured memory_bytes: 3076
N = int(input())
i = 0
count = 0
for num in range(1, N+1):
    a, b = map(int, input().split())
    if a == b:
        i += 1
    else:
        i = 0
    if i == 3:
        count = 1
if count >= 1:  
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62480
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cstring>
#include <iomanip>
using namespace std;

int main(){
    long long one=0,zero=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0') zero++;
        if(s[i]=='1') one++;
    }
    if(zero>=one) cout<<one*2;
    else cout<<zero*2;
}


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

int main()
{
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);

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

  if (vec.at(0) == 5 && vec.at(1) == 5 && vec.at(2) == 7)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3584
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, K;
    cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <random>
#include <array>
#include <chrono>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

using llint=long long;

llint scoring(vector<llint> c,
            vector<vector<llint>> s,
            vector<llint> result,
            llint d=365){
    
    if(c.size()!=s[0].size()||s.size()!=result.size()){
         return -1;
    }else{
        llint score=0;
        REP(i,d){
            score+=s[i][result[i]-1];
            REP(j,26){
                if(j+1!=result[i]){
                    score-=c[j];
                }
            }
        }
        return score;
    }
 }

int main(){
    chrono::system_clock::time_point start, end;
    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    start = chrono::system_clock::now();
    llint d;
    cin>>d;
    std::uniform_int_distribution<> rand26(1, 26),randd(0,d-1);        // [0, 99] 範囲の一様乱数
    
    llint anum=26;
    vector<llint> c(anum);
    
    REP(i,anum){
        cin>>c[i];
    }
    vector<vector<llint>> s(d,vector<llint>(anum));
    REP(i,d){
        REP(j,anum){
            cin>>s[i][j];
        }
    }
    vector<llint> result(d);

    REP(i,d){
        result[i]=1+i%26;
    }
    double time;
    while(( time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(
        ( end = chrono::system_clock::now()) - start).count()
        ))<1800){
        auto newresult=result;
        REP(i,3){
            newresult[randd(mt)]=rand26(mt);
        }
        if(scoring(c,s,newresult,d)>scoring(c,s,result,d)){
            result=newresult;
        }
    }
    REP(i,d){
        cout<<result[i]<<endl;
    }
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;
  int memo = INF;
  int ssum = s.size(), tsum = t.size();
  for(int i = 0;i <= ssum - tsum;i ++){
    bool out = false;
    for(int j = 0;j < tsum;j ++){
      if(s[i + j] != t[j] && s[i + j] != '?'){
	out = true;
	break;
      }
    }
    if(!out){
      memo = i;
    }
  }
  if(memo == INF){
    cout << "UNRESTORABLE\n";
  } else {
    rep(i, ssum){
      if(i == memo){
	cout << t;
	i += tsum - 1;
      } else {
	if(s[i] == '?'){
	  cout << 'a';
	} else {
	  cout << s[i];
	}
      }
    }
    cout << '\n';
  }
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll S=0;
	FOR(i,N) {
		cin>>A[i+1];
		S+=abs(A[i+1]-A[i]);
	}
	S+=abs(A[N]);
	ll ret=S;
	for(i=1;i<=N;i++) cout<<S-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i-1]-A[i+1])<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll ans = 0;

struct Data {
  ll N, M, Q;
  vector<ll> a, b, c, d;
  Data(ll N, ll M, ll Q, vector<ll>& a, vector<ll>& b, vector<ll>& c,
       vector<ll>& d)
      : N(N), M(M), Q(Q), a(a), b(b), c(c), d(d){};
};

void dfs(int index, Data& D, vector<ll>& A) {
  if (index == D.N) {
    ll score = 0;
    for (int i = 0; i < D.Q; i++) {
      if (A[D.b[i]] - A[D.a[i]] == D.c[i]) score += D.d[i];
    }
    ans = max(ans, score);
    return;
  }
  for (int i = A[index - 1]; i <= D.M; i++) {
    A[index] = i;
    dfs(index + 1, D, A);
  }
  return;
}

int main() {
  ll N, M, Q;
  cin >> N >> M >> Q;
  vector<ll> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  vector<ll> A(N, 1);
  Data D = Data(N, M, Q, a, b, c, d);
  dfs(1, D, A);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define ld long double
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define F first
#define S second
#define L length
#define mp make_pair
#define PI 3.14159265
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int i=0;i<n;i++)
#define forf(i,x,n) for(int i=x;i<n;i++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
#define take(a,n) forup(i,n) cin>>a[i];
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

ll poww(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n==1) return x;
    else if(n%2 == 0)        //n is even
        return poww(x*x,n/2);
    else                              //n is odd
        return x*poww(x*x,(n-1)/2);
}

ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}

template<typename T>
T maxx(T a,T b)
{
  if(a<b) re b;
  re b;
}
template<typename T, typename... Args>
T maxx(T a,T b, Args... args)
{
    re(maxx(maxx(a,b),args...));
}

template<typename T>
T minn(T a,T b)
{
  if(a<b) re a;
  re b;
}
template<typename T, typename... Args>
T minn(T a,T b, Args... args)
{
    re(minn(minn(a,b),args...));
}

int gcd(int a, int b)
{
    if (a == 0)
       return b;
    if (b == 0)
       return a;

    if (a == b)
        return a;

    if (a > b)
        return gcd(a-b, b);
    else return gcd(a, b-a);
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}

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

  int t=1;
  //cin>>t;
  while(t--)
  {
    ll n,m,k;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
      if(s[i]=='7'){cout<<"Yes";re 0;}
    }

    cout<<"No";

  }


  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    int anew = a.size();

    if(n == anew) {
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
N = int(input())
T, A = map(int, input().split())
H_lst = list(map(int, input().split()))
min_remainder = 1000
min_index = -1
for i in range(N):
    temperature = T - H_lst[i] * 0.006
    tmp_remainder = abs(A - temperature)
    if tmp_remainder < min_remainder:
        min_remainder = tmp_remainder
        min_index = i + 1

print(min_index)


Measured memory_bytes: 3060
using System;
using System.Linq;

class C
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split().Select(int.Parse).GroupBy(x => x).SelectMany(g => g.Take(2)).ToArray();

		var M = a[1];
		for (int j = 2; j < a.Length; j++)
			if ((M = Gcd(M, a[j])) == 1) break;

		for (int i = 1; i < a.Length; i++)
		{
			var g = a[0];
			for (int j = 1; j < a.Length; j++)
			{
				if (j == i) continue;
				if ((g = Gcd(g, a[j])) <= M) break;
			}
			M = Math.Max(M, g);
		}
		Console.WriteLine(M);
	}

	static int Gcd(int x, int y) { for (int r; (r = x % y) > 0; x = y, y = r) ; return y; }
}


Measured memory_bytes: 28252
#include <iostream>
#include <vector>
#include <algorithm>

struct TCard
{
    char Suit;
    int  Num;
    bool operator==(const TCard& C)const
    {
        return Suit == C.Suit && Num == C.Num;
    }
    bool operator <(const TCard& C)const
    {
      return Num < C.Num;
    }
    bool operator <=(const TCard& C)const
    {
        return Num <= C.Num;
    }
};
typedef std::vector<TCard> TList;

int partition(TList& A, int p, int r)
{
  int i = p - 1;
  for(int j = p; j < r; ++j){
    if(A[j] <= A[r]){
      i = i + 1;
      std::swap(A[i],A[j]);
    }
  }
  std::swap(A[i+1],A[r]);
  return i+1;
}

void quickSort(TList& A, int p, int r)
{
  if(p < r){
    int q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i].Suit;
        std::cin >> List[i].Num;
    }
    return List;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << It->Suit << " " << It->Num;
    for(++It; It != List.end(); ++It){
        std::cout << "\n" << It->Suit << " " << It->Num;
    }
    std::cout << std::endl;
}
void Check(const TList& List, const TList& Stable)
{
    if(std::equal(List.begin(), List.end(), Stable.begin())){
        std::cout << "Stable" << std::endl;
    }else{
        std::cout << "Not stable" << std::endl;
    }
}

int main()
{
    const TList List = Input();
    TList StableList = List;
    std::stable_sort(StableList.begin(), StableList.end());

    TList QuickList = List;
    quickSort(QuickList, 0, QuickList.size() - 1);
    Check(QuickList, StableList);
    Output(QuickList);
    return 0;
}

Measured memory_bytes: 5168
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#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 all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    ll h, w;
    cin >> h >> w;

    if(h == 1 || w == 1) return cout << 1 << endl, 0;

    ll harf = h * w / 2;
    if(h % 2 == 0 || w % 2 == 0) cout << harf << endl;
    else cout << harf + 1 << endl;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,X,Y;
int ma,mb;
int main()
{
	int a;
	int x=-1e9,y=1e9;
	scanf("%d%d%d%d",&n,&m,&X,&Y);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a);
		x=max(a,x);
	}
	for(int i=1;i<=m;i++) {
		scanf("%d",&a);
		y=min(a,y);
	}
	for(int i=X+1;i<=Y;i++)
		if(i>x&&i<=y) {
			printf("No War");
			return 0;
		}
	printf("War");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>

using namespace std;

int a = 0;
int b = 0;

void get_input()
{
	cin >> a >> b;
	return;
}

int main()
{
	get_input();

	if(a == b)
	{
		cout << "Draw";
	}
	else if(a == 1)
	{
		cout << "Alice";
	}
	else if(b == 1)
	{
		cout << "Bob";
	}
	else if(a > b)
	{
		cout << "Alice";
	}
	else
	{
		cout << "Bob";
	}

	return 0;
}

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

N, X = map(int, input().split())
burger_len = [1]

for i in range(N):
    burger_len += [ burger_len[i] * 2 + 3 ]

def rec(N, X):
    if X == 1:
        return 1 if N == 0 else 0
    elif 1 < X <= burger_len[N-1] + 1:
        return rec(N-1, X-1)
    elif X == burger_len[N-1] + 2:
        return rec(N-1, burger_len[N-1]) + 1
    elif burger_len[N-1] + 2 < X < burger_len[N]:
        return rec(N-1, burger_len[N-1]) + \
        1 + rec(N-1, X - burger_len[N-1] - 2)
    elif X == burger_len[N]:
        return rec(N-1, burger_len[N-1]) * 2 + 1

print (rec(N, X))


Measured memory_bytes: 3064