akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

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

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)

const int M=32;
bool dp[100001][M][M];
bool par[100001][M][M];

int main() {
	IO;
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	vector<string> lst(n+1);
	for(int i=1;i<=n;++i) cin>>lst[i];
	dp[0][min(a,M/2)][min(b,M/2)]=1;
	int sum=min(a,M/2)+min(b,M/2)+min(c,M/2);
	for(int i=1;i<=n;++i) {
		for(int j=0;j<M;++j) {
			for(int k=0;k<M;++k) {
				array<int,3> state={j,k,sum-j-k};
				for(int x=0;x<2&&state[2]>=0;++x) {
					array<int,3> nstate=state;
					nstate[lst[i][x]-'A']=nstate[lst[i][x]-'A']+1;
					nstate[lst[i][1-x]-'A']--;
					if(min(nstate[0],min(nstate[1],nstate[2]))>=0 && max(nstate[0],max(nstate[1],nstate[2]))<M) {
						//~ LOG("wat");
						if(dp[i-1][nstate[0]][nstate[1]]) {
							dp[i][j][k]=1;
							par[i][j][k]=x;
							//~ cerr<<i<<" "<<j<<" "<<k<<" "<<l<<" ! "<<state[0]<<" "<<state[1]<<" "<<state[2]<<" "<<x<<"\n";
						}
					}
				}
			
			}
		}
	}
	
	array<int,3> state={-1,-1,-1};
	for(int i=0;i<M;++i) {
		for(int j=0;j<M;++j) {
		
			if(dp[n][i][j] && sum-i-j>=0) {
				
				state={i,j,sum-i-j};
				//~ cerr<<i<<" "<<j<<" "<<k<<"\n";
				//~ cerr<<par[n][i][j]<<"\n";
			}
			
		}
	}
	
	
	if(state[0]==-1) {
		cout<<"No\n";
	}else {
		cout<<"Yes\n";
		string ans;
		while(n>0) {
			int x=par[n][state[0]][state[1]];
			//~ cerr<<state[0]<<" "<<state[1]<<" "<<state[2]<<"\n";
			ans.pb(lst[n][1-x]);
			state[lst[n][x]-'A']=state[lst[n][x]-'A']+1;
			state[lst[n][1-x]-'A']--;
			n--;
		}
		
		reverse(all(ans));
		for(auto i:ans) cout<<i<<"\n";
	}

	return 0;
}


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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

typedef long long ll;
ll x, k, d, ans, mydiv, q;

int main(){
    cin >> x >> k >> d;
    if(x < 0) x = -x;

    mydiv = x/d;
    q = x % d;

    if(k < mydiv) ans = x - k*d;
    else if ((k-mydiv) % 2 == 1) ans = d - q;
    else ans = q;

    cout << ans << endl;
}

Measured memory_bytes: 3536
#include <stdio.h>

    /*
     *軸要素の選択
     *順にみて、最初に見つかった異なる2つの要素のうち、
     *大きいほうの番号を返します。
     *全部同じの要素の場合は -1 を返します。
    */
int pivot(int *a, int i, int j) {
    int k = i + 1;
    while(k <= j && a[i] == a[k]) k++;
    if (k > j) {
        return -1;
    } else if (a[i] >= a[k]) {
        return i;
    }
    return k;
}


  /*
   * パーティション分割
   * a[i]～a[j]の間で、x を軸として分割します。
   * x より小さい要素は前に、大きい要素はうしろに来ます。
   * 大きい要素の開始番号を返します。
   */
   int partition(int *a, int i, int j, int x) {
       int l = i, r = j;

       // 検索が交差するまで繰り返します
       while (l <= r) {

           // 軸要素以上のデータを探します
           while (l <= j && a[l] < x)  l++;

           // 軸要素未満のデータを探します
           while (r >= i && a[r] >= x) r--;

           if(l > r) break;
           int t = a[l];
           a[l]  = a[r];
           a[r]  = t;
           l++;
           r--;
        }

        return l;
    }

    /*
    * クイックソート（再帰用）
    * 配列aの、a[i]からa[j]を並べ替えます。
    */
    void quickSort(int *a, int i, int j) {
        if(i == j) return;
        int p = pivot(a, i, j);
        if(p != -1) {
            int k = partition(a, i, j, a[p]);
            quickSort(a, i, k-1);
            quickSort(a, k, j);
        }
    }

    /*
    * メイン関数
    * 基本処理は各メソッドに
    */
    int main() {
        int N;
        scanf("%d", &N);
        int num[N];

        for(int i = 0; i < N; i++) {
            scanf("%d", &num[i]);
    }

    quickSort(num, 0, N - 1);

    printf("%d\n", num[(N/2)] - num[(N/2) - 1]);
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long int ll;
int W,H;
int N;
int X[100000];
int Y[100000];
int XC[100000];
int YC[100000];
ll ans;
int ansx,ansy;
int main()
{
	scanf("%d%d",&W,&H);
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d%d",&X[i],&Y[i]);
		XC[i]=X[i];YC[i]=Y[i];
	}
	sort(XC,XC+N);sort(YC,YC+N);
	if(N&1){
		ll ma=0;
		ansx=XC[N/2];ansy=YC[N/2];
		for(int i=0;i<N;i++){
			ans+=(ll)(abs(X[i]-ansx));
			ans+=(ll)(abs(Y[i]-ansy));
			ma=max(ma,(ll)(abs(X[i]-ansx)+abs(Y[i]-ansy)));
		}
		printf("%lld\n%d %d\n",2*ans-ma,ansx,ansy);
	}
	else{
		int ansx1=XC[N/2-1];int ansy1=YC[N/2-1];
		ll ans1=0;
		ll ma=0;
		for(int i=0;i<N;i++){
			ans1+=(ll)(abs(X[i]-ansx1));
			ans1+=(ll)(abs(Y[i]-ansy1));
			ma=max(ma,(ll)(abs(X[i]-ansx1)+abs(Y[i]-ansy1)));
		}
		ansx=ansx1;ansy=ansy1;
		ans=2*ans1-ma;
		
		ma=0;
		ans1=0;
		ansx1=XC[N/2-1];ansy1=YC[N/2];
		for(int i=0;i<N;i++){
			ans1+=(ll)(abs(X[i]-ansx1));
			ans1+=(ll)(abs(Y[i]-ansy1));
			ma=max(ma,(ll)(abs(X[i]-ansx1)+abs(Y[i]-ansy1)));
		}
		if(2*ans1-ma<ans){
			ans=2*ans1-ma;
			ansx=ansx1;ansy=ansy1;
		}
		
		ma=0;
		ans1=0;
		ansx1=XC[N/2];ansy1=YC[N/2-1];
		for(int i=0;i<N;i++){
			ans1+=(ll)(abs(X[i]-ansx1));
			ans1+=(ll)(abs(Y[i]-ansy1));
			ma=max(ma,(ll)(abs(X[i]-ansx1)+abs(Y[i]-ansy1)));
		}
		if(2*ans1-ma<ans){
			ans=2*ans1-ma;
			ansx=ansx1;ansy=ansy1;
		}
		
		ma=0;
		ans1=0;
		ansx1=XC[N/2];ansy1=YC[N/2];
		for(int i=0;i<N;i++){
			ans1+=(ll)(abs(X[i]-ansx1));
			ans1+=(ll)(abs(Y[i]-ansy1));
			ma=max(ma,(ll)(abs(X[i]-ansx1)+abs(Y[i]-ansy1)));
		}
		if(2*ans1-ma<ans){
			ans=2*ans1-ma;
			ansx=ansx1;ansy=ansy1;
		}
		printf("%lld\n%d %d\n",ans,ansx,ansy);
	}
	return 0;
}

Measured memory_bytes: 2764
use proconio::input;

fn main() {
    input! {
        n: i64,
        x: i64,
        m: i64,
    }

    let mut v = vec![false; m as usize + 5];
    let mut now = x;
    while !v[now as usize] {
        v[now as usize] = true;
        now = (now * now) % m;
    }
    let start_loop = now;

    let mut init_len = 0i64;
    let mut init_s = 0i64;
    let mut now = x;
    while now != start_loop {
        init_len += 1;
        init_s += now;
        now = (now * now) % m;
    }
    let init_len = init_len;
    let init_s = init_s;

    let mut loop_len = 1i64;
    let mut loop_s = start_loop;
    let mut now = (start_loop * start_loop) % m;
    while now != start_loop {
        loop_len += 1;
        loop_s += now;
        now = (now * now) % m;
    }
    let loop_len = loop_len;
    let loop_s = loop_s;

    // dbg!(start_loop, init_len, init_s, loop_len, loop_s);

    if n < init_len {
        // dbg!("route 1");
        let mut ans = 0i64;
        let mut now = x;
        for _ in 0..n {
            ans += now;
            now = (now * now) % m;
        }
        println!("{}", ans);
    } else {
        // dbg!("route 2");
        let mut ans = 0;
        let rem = n - init_len;
        ans += init_s;
        // dbg!(ans);

        ans += loop_s * (rem / loop_len);
        // dbg!(ans);

        let rem = rem % loop_len;
        let mut now = start_loop;
        for _ in 0..rem {
            ans += now;
            now = (now * now) % m;
        }

        println!("{}", ans);
    }
}


Measured memory_bytes: 2276
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;
const long long INF = 1LL << 61;

struct sol {
	long long x, cost;
	long long c;

	sol(long long xx, long long cc, long long C) {
		x = xx;
		cost = cc;
		c = C;
	}

	long long getCost(long long y) {
		long long d = y - x;
		return d * d + cost + c;
	}

	long long time(sol sol2) {
		long long l = sol2.x;
		long long r = l;

		while (getCost(r) < sol2.getCost(r)) {
			l = r + 1;
			r *= 2;
		}
		long long ans = r;

		while (l <= r) {
			long long mid = l + (r - l) / 2;
			if (getCost(mid) >= sol2.getCost(mid)) {
				ans = mid;
				r = mid - 1;
			}
			else {
				l = mid + 1;
			}
		}
		return ans;
	}
};

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

	int n;
	long long c;
	cin >> n >> c;

	vector<long long> heights;
	for (int i = 0; i < n; i++) {
		long long h;
		cin >> h;
		heights.push_back(h);
	}

	vector<long long> dp(n, INF);
	dp[0] = 0LL;
	deque<sol> all;

	all.push_back({ heights[0], 0, c });
	for (int i = 1; i < n; i++) {
		while (all.size() >= 2 && all[0].getCost(heights[i]) >= all[1].getCost(heights[i])) {
			all.pop_front();
		}
		dp[i] = all[0].getCost(heights[i]);
		sol add(heights[i], dp[i], c);
		while (all.size() >= 2 && all[all.size() - 2].time(all[all.size() - 1]) > all[all.size() - 1].time(add)) {
			all.pop_back();
		}
		all.push_back(add);
	}

	cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 9468
#include <iostream>
#include <cstring>
 
using namespace std;
 
#define MAX 35
 
int H,W,N;
char field[MAX][MAX];
bool flg;
 
bool inField(int y,int x){
    return 0 <= y && y < H && 0 <= x && x < W;
}
 
void del(){
    bool rem[MAX][MAX];
    memset(rem,false,sizeof(rem));
    for(int y = 0 ; y < H ; y++){
	for(int x = 0 ; x < W ; x++){
	    if(field[y][x] == '.') continue;
	    int n = 0, nx = x, ny = y; 
	    char ch = field[y][x];
	    while(true){
		if(!inField(ny,nx)) break;
		if(field[ny][nx] != ch) break;
		n++; nx++;
	    }
	    if(n >= N){
		for(int j = 0 ; j < n ; j++){
		    rem[y][nx-j-1] = true;
		}
	    }
	    nx = x, ny = y, n = 0;
	    while(true){
		if(!inField(ny,nx)) break;
		if(field[ny][nx] != ch) break;
		n++; ny++;
	    }
	    if(n >= N){
		for(int j = 0 ; j < n ; j++){
		    rem[ny-j-1][x] = true;
		}
	    }
	}
    }
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    if(rem[i][j]){
		flg = true;
		field[i][j] = '.';
	    }
	}
    }
}
 
void fall(){
    char t[MAX][MAX];
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    t[i][j] = '.';
	}
    }
   
    for(int j = 0 ; j < W ; j++){
	int idx = H-1;
	for(int i = H-1 ; i >= 0 ; i--){
	    if(field[i][j] == '.') continue;
	    t[idx--][j] = field[i][j];
	}
    }
 
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    field[i][j] = t[i][j];
	}
    }
}
 
bool check(){
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    if(field[i][j] != '.') return false;
	}
    }
    return true;
}
 
bool solve(){
    if(check()) return true;
    flg = false; del(); 
    if(flg){
	fall(); 
	if(solve()) return true;
    }
    return false;
}
 
int main(){
    cin >> H >> W >> N;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    cin >> field[i][j];
	}
    }
    char tmp[MAX][MAX];
    bool ok = false;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W-1 ; j++){
	    if(field[i][j] == field[i][j+1]) continue;
	    for(int k = 0 ; k < H ; k++){
		for(int l = 0 ; l < W ; l++){
		    tmp[k][l] = field[k][l];
		}
	    }
	    swap(field[i][j],field[i][j+1]);
	    if(field[i][j] == '.' || field[i][j+1] == '.'){
		fall();
	    }
	    if(solve()){
		ok = true;
		goto end;
	    }
	    for(int k = 0 ; k < H ; k++){
		for(int l = 0 ; l < W ; l++){
		    field[k][l] = tmp[k][l];
		}
	    }
	}
    }
end:;
    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3076
N = int(input())
A = list(map(int,input().split()))
def f(m):
    sum = 0
    for a in A:
        sum += m % a
    return sum
# max = 0
# for i in range(0, 1000000):
#     N = f(i)
#     if N > max:
#         max = N
# print(max) # rangeの範囲じゃ限界しかない
A = map(lambda x: x - 1, A)
print(sum(A))

Measured memory_bytes: 3316
import math
n, m = map(int,input().split(' '))
d = list(map(int,input().split(' ')))
d.sort()
inf = n

dp = [ [ inf for i in range(m+1)] for j in range(n+1) ]

# dp
for j in range(m+1):
    dp[0][j]=0

for j in range(m-1,-1,-1):
    for i in range(n+1):
        #for k in range(math.floor(i/d[j])+1):
        if math.floor(i/d[j]) >=1:
            k=1
        else:
            k=0
        r = k*d[j]
        #print(i,j,k)
        dp[i][j] = min( dp[i][j], dp[i][j+1], dp[i-r][j]+k ) 
        #print("dp:",i,j,dp[i][j])
print(dp[n][0])



Measured memory_bytes: 20616
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,m,c,b[20],ans=0;
  cin >> n >> m >> c;
  for(int i=0; i<m; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n; i++) {
    int cnt=0;
    for(int j=0; j<m; j++) {
      int a;
      cin >> a;
      cnt+=a*b[j];
    }
    if(cnt+c>0) {
        ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
while (fscanf(STDIN, "%d %d %d", $n, $m, $p) && ($n | $m | $p)) {
  $x = array();
  $count = 0;
  for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d", $x[$i]);
    $count += $x[$i];
  }
  if ($x[$m - 1]) {
    $ans = floor($count * (100 - $p) / $x[$m - 1]);
  } else {
    $ans = 0;
  }
  print $ans . "\n";
}

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

ll a[210000];
main(){
    ll n,h,A,m,r,ans=1e10;
    cin>>h>>A;
    cout<<ceil((ld)h/A);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <math.h>

#define LL long long
#define MOD 1000000007
#define rep(i,n) for(int i = 0;i < (n);i++)

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> A(N);
    for(int i = 1; i < N;i++) cin >> A[i];

    vector<int> ans(N);
    rep(i,N) ans[i] = 0;

    for(int i = 1; i < N;i++){
        ans[A[i]-1]++;
    }


    rep(i,N) cout << ans[i] << endl;


    return 0;

}

Measured memory_bytes: 4756
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int len;
    cin >> len;
    cin.get();

    string str;
    getline(cin, str);

    auto level = 0;
    auto min_level = level;

    for (const auto &ch : str) {
        level += (ch == '(' ? 1 : -1);
        min_level = min(min_level, level);
    }

    cout << string(-min_level, '(');
    cout << str;
    cout << string(level - min_level, ')');
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
/**

    WARNING
          This Code Sucks
                        Just Like My Life :(

**/
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template<class T> using orderd_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int n, k, cost[4][N], dp[N][4];
int main(){
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d%d%d",&cost[1][i],&cost[2][i],&cost[3][i]);
    dp[0][0] = 0;
    int ans = 0;
    for(int i = 1; i <= n ; i++){
        int temp = 0;
        for(int j = 1 ; j <= 3 ; j++){
            for(int k = 1 ; k <= 3 ; k++){
                if (k != j)
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + cost[j][i]);
            }
            if (i == n)
                ans = max(dp[i][j], ans);
        }
    }
    printf("%d",ans);
    return 0;
}


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

const int N =2*1e5+5;

vector<int>adj[N];
int frr[N];
bool vis[N];
int cnt;

void dfs(int u)
{
    vis[u]=true;
    frr[cnt]++;
    for(int i=0;i<adj[u].size();i++)
    {
        int v=adj[u][i];
        if(!vis[v])
        {
            dfs(v);
        }
    }
}


int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)vis[i]=false;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
           cnt++;
           dfs(i);
        }
    }
    int sum=0;
    if(cnt<2)
    {
        cout<<frr[1]<<endl;
        return 0;
    }
    //int sum=0;
    else
    {
        for(int i=1;i<=N;i++)
        {
            if(frr[i]==0)break;
            else
            {
                sum=max(sum,frr[i]);
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 20940
ri = lambda S: [int(v) for v in S.split()]
def rii(): return ri(input())

N = int(input())
A = [v for v in rii() if v % 2 == 0]

print("APPROVED" if all(v % 3 == 0 or v % 5 == 0 for v in A) else "DENIED")

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//

int main() {
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1;
	}
	else {
		cout << (H * W + 1) / 2;
	}
}


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

int main(int argc, const char * argv[]) {
    char cards[201], sub[201];
    int m, h;
    while(1){
        scanf("%s", cards);
        if(strcmp(cards, "-") == 0) break;
        scanf("%d", &m);
        for(int i=0; i<m; i++){
            scanf("%d", &h);
            strncpy(sub, cards, h);
            sub[h] = '\0';
            memmove(cards, &cards[h], strlen(cards));
            strcat(cards, sub);
        }
        printf("%s\n", cards);
    }
    return 0;
}



Measured memory_bytes: 2052
#include<stdio.h>
 int main(){
	 int N,K,L;
	 int ans = 1;
	 scanf("%d %d", &N, &K);
   L=K;
     

	 for(int a=0;a<N;a++){
		 if(N/K>0){
			 ans++;
			 K *= L;
		 }else{
			 printf("%d", ans);
			 return 0;
		 }
	 }
 }

Measured memory_bytes: 128
#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;
    if((b*10+c)%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    unsigned long long n, m; cin >> n >> m;
    vector<tuple<unsigned long long, unsigned long long> > a;

    unsigned long long x, y;    
    for(unsigned long long i=0;i<n;++i) {
        cin >> x >> y;
        a.push_back(make_tuple(x,y));
    }
    sort(a.begin(), a.end());
    unsigned long long j=0uLL, v=0uLL;
    while(m>0) {
        if(m>get<1>(a[j])) {
            v += get<0>(a[j]) * get<1>(a[j]);
            m-=get<1>(a[j]);
        } else {
            v += get<0>(a[j]) * m;
            m=0;
        }
        ++j;
    }
    cout << v << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

int a[5][5];
int main()
{
    int n;
    int b[5][5];
    cin >> n;
    for(int lim=0;lim<n;lim++)
    {
        int M=0;
        int m;
        for(int i=0;i<5;i++)
        {
            int count=1;
            for(int j=0;j<5;j++)
            {
                cin >> b[i][j];
            }
            for(int j=4;j>=0;j--)
            {
                if(b[i][j] == 0) count = 0;
                a[i][j] = count;
                ++count;
            }
        }
        /*
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
            {
                cout << a[i][j];
            }
            cout << endl;
        }
        */
        for(int i=0;i<5;i++)
        {
            for(int j=0;j<5;j++)
            {
                if(a[i][j] != 0){
                    m = a[i][j];
                    for(int k=1;i+k-1<5 && a[i+k-1][j] != 0;k++)
                    {
                        //printf("(%d,%d) = %d, (M,m) = (%d,%d)\n",i+k-1,j,a[i+k][j],M,m);
                        m = min(m, a[i+k-1][j]);
                        M = max(M, k*m);
                    }
                }
            }
        }
        cout << M << endl;
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>
#include<bitset>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  ll k,a,b;
  cin>>k>>a>>b;
  ll kk=k+1;
  if(b-a<=2||kk<a){
    cout<<kk<<"\n";
  }else{
    ll conv=(kk-a)/2;
    ll ret=(kk-conv*2)+(b-a)*conv;
    cout<<ret<<"\n";
  }

}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::string str;
    std::cin >> str;
    if (str == "Sunny") {
        std::cout << "Cloudy" << std::endl;
    } else if (str == "Cloudy") {
        std::cout << "Rainy" << std::endl;
    } else if (str == "Rainy") {
        std::cout << "Sunny" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char a,b,c;
	
	int count=0;
	
	scanf("%c%c%c",&a,&b,&c);getchar();
	
	if(a=='1'){
		count++;
	}
	
	if(b=='1'){
		count++;
	}
	
	if(c=='1'){
		count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//

// https://atcoder.jp/contests/abc123/tasks/abc123_d

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ull> Ais;
	vector<ull> Bis;
	vector<ull> Cis;
	for (int i = 0; i < X; i++) {
		ull v;
		cin >> v;
		Ais.push_back(v);
	}
	for (int i = 0; i < Y; i++) {
		ull v;
		cin >> v;
		Bis.push_back(v);
	}
	for (int i = 0; i < Z; i++) {
		ull v;
		cin >> v;
		Cis.push_back(v);
	}
	std::sort(Ais.begin(), Ais.end(), std::greater<ull>());
	std::sort(Bis.begin(), Bis.end(), std::greater<ull>());
	std::sort(Cis.begin(), Cis.end(), std::greater<ull>());
	vector<ull> values;
	for (int x = 1; x <= X; x++) {
		for (int y = 1; y <= Y && x*y <= K; y++) {
			for (int z = 1; z <= Z && x*y*z <= K; z++) {
				values.push_back(Ais[x-1]+Bis[y-1]+Cis[z-1]);
			}
		}
	}
	std::sort(values.begin(), values.end(), std::greater<ull>());
	for(int i = 0; i < K; i++) {
		cout << values[i] << endl;
	}
}

Measured memory_bytes: 1412
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k, t;
	cin >> k >> t;
	int mx = 0;
	rep(i,t){
		int a;
		cin >> a;
		chmax(mx, a);
	}
	int ans = 0, oth = k - mx;
	bool flag = false;
	rep(i,k){
		if(i%2 == 0){
			if(mx <= 0){
				cout << 0 << endl;
				return 0;
			}
			--mx;
		}
		else{
			if(oth <= 0){
				cout << mx << endl;
				return 0;
			}
			--oth;
		}
	}
	cout << mx << endl;
	return 0;
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const ll MXN = 1e18;


map<ll, int> mp;
void factor(ll n){
	for (ll i = 2; i*i <= n; ++i)
	{
		if(n%i == 0){
			while(n%i == 0){
				mp[i]++;
				n /= i;
			}
		}
	}
	if(n>1){
		mp[n]++;
	}
}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll n; cin>>n;
   factor(n);
   int ans = 0;
   for(auto aa: mp){
   	long double p = aa.second;
   	int val = (sqrt(1+8*p)-1)/2;
   	ans +=val;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3696
N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    A[i], B[i], C[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]  # 初期化　[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] for n = 4
dp[0] = [A[0], B[0], C[0]]

for i in range(N-1):
    dp[i+1][0] = max(dp[i][1]+A[i+1], dp[i][2]+A[i+1])
    dp[i+1][1] = max(dp[i][0]+B[i+1], dp[i][2]+B[i+1])
    dp[i+1][2] = max(dp[i][0]+C[i+1], dp[i][1]+C[i+1])
print(max(dp[N-1]))

Measured memory_bytes: 34616
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int len, l;
char s[15], p[15];

int main()
{
    scanf("%s", s + 1);
    len = strlen(s + 1);
    for (int i = 1; i <= len; ++ i)
    {
        if (s[i] == '0' || s[i] == '1')
            p[++ l] = s[i];
        else 
            -- l;
        l = max(l, 0);
    }
    for (int i = 1; i <= l; ++ i)
        printf("%c", p[i]);
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger A = new BigInteger(sc.next()), B = new BigInteger(sc.next());
		sc.close();
		System.out.println(A.remainder(B));
	}
}


Measured memory_bytes: 26468
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	string w[110];
	for(int i=1;i<=n;i++)
		cin >> w[i-1];
	
	bool flag=true;

	for(int i=1;i<=n;i++)
	{
		if(i!=1 && w[i-1-1][w[i-1-1].size()-1]!=w[i-1][0])
		{
			flag=false;
			break;
		}
		for(int j=1;j<=i-1;j++)
		{
			if(w[i-1]==w[j-1])
			{
				flag=false;
				break;
			}
		}
	}

	cout << (flag==true ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n = int(input())
L = list(sorted(map(int, input().split())))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if L[i] == L[j]: continue
        for k in range(j+1, n):
            if L[j] == L[k]: continue
            if L[i] + L[j] > L[k]: ans += 1
print(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> so,v;
ll ans;
void dfs(int d,int t){
  if(d==v.size()){
    ans+=t;
    return;
  }
  for(int i=0;i<=v[d];i++){
    int nt=t;
    if(v[d]==i)nt*=i+1;
    dfs(d+1,nt);
  }
}
 
int main(){
  ll n;
  while(cin>>n&&n){
    ans=1;
    v.clear();
    ll tmp=n;
    for(ll i=2;i*i<=n;i++)
      if(tmp%i==0){
	v.push_back(0);
	while(tmp%i==0)tmp/=i,v[v.size()-1]++;
      }
    if(tmp>1)v.push_back(1);
    dfs(0,1);
    cout<<ans/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
S = list(input())
S.pop(-1)
while True:
    if len(S)%2 != 0:
        S.pop(-1)
    c = 0
    for i in range(len(S)//2):
        if S[i] != S[i+len(S)//2]:
            c = 1
            del S[-2:]
            break
    if c == 0:
        break
print(len(S))

Measured memory_bytes: 3060
### -*- coding: utf-8 -*-

N = int(input())
nums = list(map(int, input().split()))
 
hitting = 1
isHitOnce = False
for num in nums:
    if num == hitting:
        hitting += 1
        isHitOnce = True
 
if hitting == 1:
    print(-1)
else:
    print(N - (hitting - 1))

Measured memory_bytes: 24744
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>


namespace Mylib{
    using namespace std;
    
}

int main(void){
    using namespace std;
    int N;
    cin >> N;
    string tempStr;
    vector<string> vStr;
    map<string,int> MP;
    int frequent=0;
    for(int i=0;i<N;i++){
        cin >> tempStr;
        vStr.push_back(tempStr);
        MP.insert(make_pair(tempStr,0));
            
        MP[tempStr]++;
        frequent=max(frequent,MP[tempStr]);
    }
    
    /*
    sort(vStr.begin(),vStr.end());
    vStr.erase(unique(vStr.begin(),vStr.end()),vStr.end());
    for(auto x:vStr){
        if(MP[x]==frequent)
        cout << x << endl;
    }
    */
    
    
    for(auto itr=MP.begin();itr!=MP.end();itr++){
        if(itr->second==frequent)
        cout << itr->first << endl;
    }//解説を参考に差し替えてみる
    
    return 0;

}

Measured memory_bytes: 26736
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[200111],b[200111];
ll C[4011][4011],dp[4011][4011];
ll qpow(ll x,ll k){return k==0?1:qpow(x*x%mod,k>>1)*(k&1?x:1)%mod;}
int main()
{
	for(int i=0;i<=4004;i++)C[i][0]=C[0][i]=1;
	for(int i=1;i<=4004;i++)
	{
		for(int j=1;j<=4004;j++)
		{
			C[i][j]=(C[i-1][j]+C[i][j-1])%mod;
		}
	}
	geti(n);
	for(int i=1;i<=n;i++)
	{
		getii(a[i],b[i]);
		dp[2002-a[i]][2002-b[i]]++;
//		cerr<<a[i]<<" "<<b[i]<<" "<<C[a[i]][b[i]]<<endl;
	}
	for(int i=1;i<=4010;i++)
	{
		for(int j=1;j<=4010;j++)
		{
			dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
//		cerr<<dp[2002+a[i]][2002+b[i]]<<endl;
		ans=(ans+dp[2002+a[i]][2002+b[i]])%mod;
		ans=(ans-C[2*a[i]][2*b[i]]+mod)%mod;
	}
	cout<<ans*qpow(2,mod-2)%mod<<endl;
	return 0;
}


Measured memory_bytes: 253312
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1LL<<40;

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

    ll ans = 0;
    string S;
    cin >> S;
    for(int i = 0; i < (1 << S.size()-1); i++){
        int last = 0;
        int cnt = 0;
        //cout << "[" << i << "]" << endl;
        for(int j = 0; j < S.size(); j++){
            if(i & (1<<j)){
                //cout << "*" << j << "*";
                ans += stoi(S.substr(last, j - last + 1));
                //cout << S.substr(last, j - last + 1) << " ";
                last = j+1;
            }
        }
        //cout << S.substr(last, S.size() - last) << " ";
        ans += stol(S.substr(last, S.size() - last));
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;

ll gcd(ll a, ll b) {
	return (!a || !b) ? 0 : ((a % b == 0) ? b : gcd(b, a % b));
}

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

int main() {
	//Code Line

	cin >> c >> n;
	cout << lcm(c, n) << endl;

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;

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


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


int main(){
  ll a,b,c,n;
  cin >> n ;
  if(n==0){
    cout<<2<<endl;
  }else if(n==1){
    cout<<1<<endl;
  }else{
    b=1,c=2;
    for(int i=0;i<n-1;i++){
      a=b+c;
      c=b;
      b=a;
    }
    cout<<b<<endl;
  }
   
}

Measured memory_bytes: 3540
/**
    __author__ : srv_twry
**/

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}

bool ge(const ll& a, const ll& b) { return a >= b; }
bool le(const ll& a, const ll& b) { return a <= b; }
bool eq(const ll& a, const ll& b) { return a == b; }
bool gt(const ll& a, const ll& b) { return a > b; }
bool lt(const ll& a, const ll& b) { return a < b; }
int sgn(const ll& x) { return le(x, 0) ? eq(x, 0) ? 0 : -1 : 1; }
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	string s; cin>>s;
	FOR(i, 1, s.size() + 1) {
		char c = s[i-1];
		if(i % 2 == 0) {
			if(c == 'R') {
				cout<<"No";
				return 0;
			}
		} else {
			if(c == 'L') {
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
long long INF = 1e18;
int main(){
  int N, K;
  scanf("%d %d", &N, &K);
  long long a[N];
  for(int i = 0; i < N; i++) scanf("%lld", &a[i]);
  long long ans = INF;
  for(int i = 0; i < N; i++){
      if(i + K - 1 >= N) break;
      long long b = a[i], c = a[i + K - 1];
      if(b < 0 && c >= 0) ans = min(ans, llabs(c) + llabs(b) + min(llabs(c), llabs(b)));
      else ans = min(ans, max(llabs(b), llabs(c)));
  }
  printf("%lld\n", ans);
}


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

int main(void){
    int n;
    cin >> n;
    
    int a[100000] = {0};
    int i;
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a, a + n, greater<int>());
    
    long long lg = 0, st = 0;
    i = 0;
    while(i < n){
        if(a[i] == a[i + 1]){
            if(lg == 0){
                lg = a[i];
            }else{
                st = a[i];
                break;
            }
            i++;
        }
        i++;
    }
    
    cout << lg * st << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;  //to use policy based data structures like indexed_set  "never used yet !! "
#define vi vector<int>
#define f first
#define s second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
    int flag=0;
    for(long long i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            flag=1;
            break;
        }
    }
    if(n==1)
	   return false;
    else if(flag==0 || n==2 ||n==3)
    {
        return true;
    }
    else
    {
        return false;
    }

}

int binaryExponentiation(int x,int n)//function to calculate x raise to power n
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(0);
   #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
    //_______________________________-code starts-______________________________________________________________________________

string s;
cin>>s;
int n=s.length();int flag=0;
zip(i,0,n)
{
	if(s[i]=='7')
	{
		flag=1;break;
	}
}
if(flag==1)
{
	cout<<"Yes"<<en;
}
else
{
	cout<<"No"<<en;
}

  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define N 200005
using namespace std;
int n,a[N],cur;
class Segment_T{
	struct tree{
		int lc,rc,v,f;
		void set(){
			v=0;f=1;
		}
	}t[N*100];
	int root,sz;
	bool flag;
	void pushdown(int x){
		if(t[x].f){
			if(t[x].lc) t[t[x].lc].set();
			if(t[x].rc) t[t[x].rc].set();
			t[x].f=0;
		}
	}
	void cover(int &x,int l,int r,int L,int R){
		if(!x) x=++sz,t[x].lc=t[x].rc=t[x].v=t[x].f=0;
		if(L<=l && R>=r){
			t[x].set();return ;
		}
		pushdown(x);
		int mid=(l+r)>>1;
		if(L<=mid) cover(t[x].lc,l,mid,L,R);
		if(R>mid) cover(t[x].rc,mid+1,r,L,R);
	}
	void modify(int &x,int l,int r,int p){
		if(!x) x=++sz,t[x].lc=t[x].rc=t[x].v=t[x].f=0;
		if(l==r){
			if(t[x].v==cur){
				flag=1;t[x].v=0;
			}
			else t[x].v++;
			return;
		}
		pushdown(x);
		int mid=(l+r)>>1;
		if(p<=mid) modify(t[x].lc,l,mid,p);
		else modify(t[x].rc,mid+1,r,p);
	}
public:
	void Cover(int l,int r){
		cover(root,1,1e9,l,r);
	}
	bool Modify(int x){
		flag=1;
		int pos=x;
		while(flag){
			flag=0;
			modify(root,1,1e9,pos);
			pos--;
			if(flag && pos==0) return 0;
		}
		return 1;
	}
	void Clear(){
		sz=0;root=0;
	}
}T;
bool pd(int x){
	cur=x;
	T.Clear();
	for(int i=1;i<=n;i++){
		if(a[i]<=a[i-1]){
			T.Cover(a[i]+1,1e9);
			if(!T.Modify(a[i])) return 0;
		}
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	bool bj=0;
	for(int i=2;i<=n;i++)
		if(a[i]<=a[i-1]){
			bj=1;break;
		}
	if(!bj){
		puts("1");return 0;
	}
	for(int i=1;i<=10;i++)
		if(pd(i)){
			printf("%d\n",i+1);
			return 0;
		}
	//for(int i=0;i<=n;i++) cout<<pd(i)<<endl;
	int L=0,R=n,mid;
	while(L<R){
		//cout<<L<<" "<<R<<endl;
		mid=(L+R)/2;
		if(!pd(mid)) L=mid+1;
		else R=mid;
	}
	printf("%d\n",L+1);
	return 0;
}

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



int main(){
  ll n,V;
  cin>>n>>V;
  
  ll A[N],B[N],C[N],D[N];
  for(int i=0;i<n;i++)cin>>A[i];
  for(int i=0;i<n;i++)cin>>B[i];
  for(int i=0;i<n;i++)cin>>C[i];
  for(int i=0;i<n;i++)cin>>D[i];
  
  map<ll,ll> M1,M2;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)M1[A[i]+B[j]]++;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)M2[(C[i]+D[j])]++;
  
  ll ans=0;
  for(map<ll,ll>::iterator I=M1.begin();I!=M1.end();I++)
    ans+=I->second*M2[V-I->first];
  cout<<ans<<endl; 
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

static const int MAX = 10000;
static const int INFTY = (1 << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  while(!q.empty()) {
    int u = q.front();
    q.pop();
    out.push_back(u);
    rep(i, 0, G[u].size()) {
      int v = G[u][i];
      indeg[v]--;
      if (indeg[v] == 0 && !V[v]) {
        V[v] = true;
        q.push(v);
      }
    }
  }
};

void tsort() {
  rep(i, 0, N)  {
    indeg[i] = 0;
  }

  rep(u, 0, N)  {
    rep(i, 0, G[u].size()) {
      int v = G[u][i];
      indeg[v]++;
    }
  }

  rep(u, 0, N)  {
    if (indeg[u] == 0 && !V[u]) bfs(u);
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }
};

int main() {
  int s, t, M;
  cin >> N >> M;

  rep(i, 0, N) {
    V[i] = false;
  }

  rep(i, 0, M) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  tsort();
};



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

int main(){
  int x,y,i=0;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0) break;
    if(x>y){
      int t=x;
      x=y;
      y=t;
    }
    cout<<x<<" "<<y<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
/*
 * Author: apikdech
 * Time: 20:04:48 15-06-2019
 * Last Modified: 20:44:20 15-06-2019
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007, N = 1e5 + 5;
int a[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, x, neg = 0, pos = 0;
	vector<pair<int, int>> ans;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0) neg++;
	}
	sort(a, a+n);
	if (neg <= 1) {
		x = a[0];
		for (int i = 1; i < n-1; i++) {
			ans.push_back({x, a[i]});
			x -= a[i];
		}
		ans.push_back({a[n-1], x});
		cout << a[n-1] - x << "\n";
	} else {
		int id = lower_bound(a, a+n, 0) - a;
		if (id == n) id--;
		x = a[id];
		for (int i = id-1; i >= 1; i--) {
			ans.push_back({x, a[i]});
			x -= a[i];
		}
		if (id == n-1) {
			ans.push_back({x, a[0]});
			x -= a[0];
			cout << x << "\n";
		} else {
			ans.push_back({a[0], x});
			x = a[0] - x;
			for (int i = id+1; i < n-1; i++) {
				ans.push_back({x, a[i]});
				x -= a[i];
			}
			ans.push_back({a[n-1], x});
			cout << a[n-1] - x << "\n";
		}
	}
	for (auto it : ans) cout << it.first << " " << it.second << "\n";
	// cerr << "time = " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << " ms\n";
	return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;

vector<int> adj[maxr];
int level[maxr];
void dfs(int root, int parent, int lvl) {
	level[root] = lvl;
	for (auto x : adj[root]) {
		if (x == parent)
			continue;
		dfs(x, root, lvl + 1);
	}
}
int ans = 0;
void dfs_t(int root, int parent, int dis) {
	if (level[root] <= dis)
		return ;
	for (auto x : adj[root]) {
		if (x == parent)
			continue;
		dfs_t(x, root, dis + 1);
	}
	ans = max(ans, level[root] - 1);
}

int32_t main()
{
	GO;
	int n, u, v;
	cin >> n >> u >> v;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(v, -1, 0);

	dfs_t(u, -1, 0);
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 13828
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <queue>
#include <string>
#define ll long long
using namespace std;
 
int main() {
  vector<ll> a;
  vector<ll> ps;
  int n; cin >> n;
  ll ps_sum = 0;
  for(int i=0; i<=n; i++){
    ll x; cin >> x;
    a.push_back(x);
    ps.push_back(ps_sum + x);
    ps_sum += x;
  }

  ll sum = 0;
  ll na = 1;
  for(int i=0; i<=n; i++){
    if(a[i]>na || (a[i]==na && i<n)){
      sum = -1;
      break;
    }
    na = min(na-a[i], ps[n]-ps[i]);
    sum += na + a[i];
    na *= 2;
  }

  cout << sum;
}

Measured memory_bytes: 5036
//
//  main.cpp
//  7
//
//  Created by 5201-mac on 17/8/12.
//  Copyright © 2017年 5201-mac. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin>>n;
    long long x,y;
    cin>>x;
    n--;
    while(n--)
    {
        cin>>y;
        long long k=__gcd(x,y);
        x=x/k*y;
    }
    printf("%lld\n",x);
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


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

int main() {
    int N, X;
    cin >> N >> X;
    int answer = 1;
    int pos = 0;
    for(int i=0;i<N;i++){
        int li;
        cin >> li;
        pos = pos + li;
        if(pos > X){
            break;
        }
        answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] array = new int[n];

        int most = 0;
        int secondMost = 0;

        for (int i = 0; i < n; i++) {
            final int next = scanner.nextInt();
            array[i] = next;

            if (next > most) {
                secondMost = most;
                most = next;
                continue;
            }

            if(next> secondMost){
                secondMost = next;
            }
        }

        for (int i = 0; i < n; i++) {
            if (array[i] == most) {
                System.out.println(secondMost);
                continue;
            }

            System.out.println(most);
        }
    }
}


Measured memory_bytes: 90760