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

int main()
{
	long int n,i;
	cin>>n;
	long int a[n],el=1,c=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]!=el)c++;
		else if(a[i]==el)
		{
			el++;
		}
	}
	if(el==1)cout<<-1;
	else cout<<c;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    cout<<k*(ll)pow(k-1,n-1)<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int N;
    cin >> N;
    if(N <= 999)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;
}

Measured memory_bytes: 3560
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(ans);
    }
}


Measured memory_bytes: 36104
using System;
using System.Collections.Generic;

class Program
{
    #region library
    static int n = 0;
    static int r = 0;
    static int c = 0;
    static int x = 0;
    static int y = 0;
    static string s = "";
    static string[] ss;
    static long sum = 0;
    static long cnt = 0;
    static long max = -1;
    static long min = 2147483647;
    static bool flg = false;
    static bool flg2 = false;
    static string alpha = "abcdefghijklmnopqrstuvwxyz";
    static int[] arr;
    static char[,] map;
    static int[,] imap;
    static string rl()
    {
        return Console.ReadLine();
    }
    static string[] rls()
    {
        return Console.ReadLine().Split();
    }
    static void wl(object obj = null)
    {
        Console.WriteLine(obj);
    }
    static void w(object obj)
    {
        Console.Write(obj);
    }
    static int Int(string s)
    {
        return int.Parse(s);
    }
    static void yes()
    {
        wl("YES");
    }
    static void no()
    {
        wl("NO");
    }
    static void Sum()
    {
        wl(sum);
    }
    static void Cnt()
    {
        wl(cnt);
    }
    static void setarray(int num = -1)
    {
        if (n == 0)
        {
            n = Int(rl());
        }
        arr = new int[n];
        if (num == -1) ss = rls();
        for (int i = 0; i < n; i++)
        {
            if (num == -1)
                arr[i] = Int(ss[i]);
            else
                arr[i] = num;
        }
    }
    static void setmap(char def = '@')
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        map = new char[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == '@') s = rl();
            for (int j = 0; j < c; j++)
            {
                map[i, j] = (def == '@') ? s[j] : def;
            }
        }
    }
    static void setimap(int def = -1)
    {
        if (r == 0 && c == 0)
        {
            ss = rls();
            r = Int(ss[0]);
            c = Int(ss[1]);
        }
        imap = new int[r, c];
        for (int i = 0; i < r; i++)
        {
            if (def == -1) s = rl();
            for (int j = 0; j < c; j++)
            {
                imap[i, j] = (def == -1) ? Int(s[j].ToString()) : def;
            }
        }
    }
    #endregion

    static void Main(string[] args)
    {
        n = Int(rl());
        wl(f(0, n));
    }

    static int f(int cnt, int n)
    {
        if(n < 6)
        {
            return cnt + n;
        }
        int a = 6;
        int cnt6 = int.MaxValue;
        while (n >= a * 6)
        {
            a *= 6;
        }
        cnt6 = f(cnt + 1, n - a);

        int cnt9 = int.MaxValue;
        if (n >= 9)
        {
            a = 9;
            while (n >= a * 9)
            {
                a *= 9;
            }
            cnt9 = f(cnt + 1, n - a);
        }

        return Math.Min(cnt6, cnt9);

    }
}



Measured memory_bytes: 11092
import collections as c
ip = lambda : map(int, input().split())
mod = 10**9+7
# ##############
N = int(input())
l = []
for i in range(N):
    a = int(input())
    l1 = []
    for j in range(a):
        l1.append(list(ip()))
    l.append(l1)
ans=0
for i in range(2**N):
    tmp = [0]*N
    t = 0
    for j in range(N):
        if i>>j & 1:
            tmp[j]=1
            t+=1
    # print(tmp)
    for j in range(N):
        if tmp[j] ==0:
            continue
        for k in l[j]:
            x,y = k
            if tmp[x-1]!=y:
                break
        else:
            continue
        break
    else:
        if t > ans:
            ans = t
    continue
print(ans)
        


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    vector<int>c;
    int d;vector<vector<int>>s;
    vector<int>last;
    auto calc=[&](int t,int day){
        int k=0;
        k+=s[day][t];
        for (int j = 0; j < 26; ++j){
            if(j==t)continue;
            else  k-=c[j]*(day+1-last[j]);
        }
        return k;
    };
    cin >>d;
    c.resize(26);
    for (int i = 0; i <26; ++i) cin >>c[i];
    s.assign(d,vector<int>(26));
    for (int i = 0; i < d; ++i)for (int j = 0; j < 26; ++j) cin >>s[i][j];
    int score=0;
    last.assign(26,0);
    vector<int>t(d);
    vector<P>p(d);
    for (int day = 0; day < d; ++day) {
        int now=-INF,now2=-INF;int d=INF;
        for (int i = 0; i < 26; ++i) {
//            if(day==4&&i==19){
//                cout <<now<<" "<<calc(i,day)<<" "<<endl;
//            }
           if(now<calc(i,day)){
               now=calc(i,day);
               t[day]=i+1;
               p[day].first=i+1;
           }
           else if(now2<calc(i,day)){
               now2=calc(i,day);
               p[day].second=i+1;
           }
        }
        last[t[day]-1]=day+1;
        score+=now;
//        cout <<score<<endl;
    }
    vector<int>copy(d);
    vector<int>lcopy(d);
    auto ucalc=[&](){
        int kk=0;
        for (int i = 0; i < d; ++i) {
            kk+=s[i][copy[i]];
            lcopy[copy[i]]=i+1;
            for (int j = 0; j < 26; ++j)score-=c[j]*(i+1-lcopy[j]);
            return kk;
        }
    };
    for (int i = 0; i < 1 << 16; ++i) {
        copy=t;lcopy=last;
        for (int j =0; j <16; ++j) {
            int k=d-j-1;
            if((1>>j)&1){
                copy[k]=p[k].second;
            }
        }
        if(score<ucalc())score=ucalc();
        t=copy;lcopy=last;
    }
    for (int i = 0; i < d; ++i) {
        cout<<t[i]<<endl;
    }
//    for (int i = 0; i < 26; ++i) {
//        cout <<last[i]<<endl;
//    }
//    cout <<score<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n;
	cin>>n;
	vector<ll> num(5);
	for(ll i = 0; i < 5; i++){
		cin>>num[i];
	}
	ll x=*min_element(all(num));
	if(x>=n){
		cout<<5<<endl;
		return 0;
	}
	if(n%x!=0) n+=x;
	for(ll i = 0; i < 5; i++){
		if(x==num[i]){
			cout<<i+n/x+(4-i)<<endl;
			return 0;
		}
	}

	return 0;
}

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

int main()
{
        int a,b,c,d,f=1;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        while(a>0 && c>0)
        {
            if(f)
            {
                c-=b;
                f^=1;
                //printf("%d\n",c);
            }
            else
            {
                a-=d;
                f^=1;
                //printf("%d\n",a);
            }
        }
        if(f)
            printf("No\n");
        else
            printf("Yes\n");

}


Measured memory_bytes: 3776
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>

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

typedef long long ll;

using namespace std;

int main(){
  int N, P[200010];
  cin >> N;
  rep(i,N) cin >> P[i];
  
  int ans=1,mi=P[0];
  for(int i = 1; i<N; i++){
    if(mi>=P[i]){
      mi = min(P[i],mi);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> V(N, 0);
  vector<int> C(N, 0);
  
  int i;
  for (i = 0; i < N; i++){
    cin >> V.at(i);
  }
  
  for (i = 0; i < N; i++){
    cin >> C.at(i);
  }
  
  int benefit = 0;
  for (i = 0; i < N; i++){
    if (V.at(i) > C.at(i)){
      benefit += V.at(i) - C.at(i);
    }
  }
  
  cout << benefit << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll INF=1LL<<60;
const ll mod=1E9+7;



int main(){
  int n;cin >> n;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  int ans=0;
  rep(i,n){
    if(i%2==0&&a[i]%2==1)ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 1E5 + 10;

int n,k,tp,Ans[maxn],f[maxn],A[maxn],cnt[maxn],nex[maxn];

vector <int> v[maxn];

void Dfs1(int x,int from)
{
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i]; if (to == from) continue;
		Dfs1(to,x); if (!f[to] && A[to] < A[x]) f[x] = 1,nex[x] = to,++cnt[x];
	}
}

void Dfs2(int x,int from,int a,bool typ)
{
	bool From = (x != 1 && !typ && a < A[x]) ? 1 : 0;
	if (x != 1 && (From || f[x])) Ans[++tp] = x;
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i];
		if (to == from) continue; bool Nex = From;
		if (f[x] && (nex[x] != to || cnt[x] > 1)) Nex = 1;
		Dfs2(to,x,A[x],Nex);
	}
}

int getint()
{
	char ch = getchar(); int ret = 0;
	while (ch < '0' || '9' < ch) ch = getchar();
	while ('0' <= ch && ch <= '9')
		ret = ret * 10 + ch - '0',ch = getchar();
	return ret;
}

int main()
{
	cin >> n; //cin >> n >> k;
	for (int i = 1; i <= n; i++) A[i] = getint();
	for (int i = 1; i < n; i++)
	{
		int x = getint(),y = getint();
		v[x].push_back(y); v[y].push_back(x);
	}
	Dfs1(1,0); Dfs2(1,0,0,0); if (f[1]) Ans[++tp] = 1;
	sort(Ans + 1,Ans + tp + 1); //cout << tp << endl;
	for (int i = 1; i < tp; i++) printf("%d ",Ans[i]);
	if (tp) cout << Ans[tp] << endl;
	return 0;
}

Measured memory_bytes: 4608
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:f64 = read();
    let b:f64 = read();
    let h:f64 = read();
    let m:f64 = read();
    let z_angle = 30.0 * h + m / 2.0;
    let m_angle = m * 6.0;
    let angle = (z_angle - m_angle).abs() * std::f64::consts::PI / 180.0;
    let ans = (a.powf(2.0) + b.powf(2.0) - 2.0*a*b * angle.cos()).sqrt();
    println!("{}", ans);
}

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

// +を入れるか入れないかを分岐させて再帰する関数
void ReFunc(vector<int> vec, int place, long long left, long long right, long long &sum)
{
    // 最後まで終わったら算出する。
    if (place == vec.size() - 1)
    {
        sum += left + right;
    }
    else
    {
        //足し算の場合、今考えている左辺と右辺を足して左辺を作り、次を右辺とする(例：123)の場合、(vec, 1, 1, 2)→(vec, 2, 3, 3)
        ReFunc(vec, place + 1, left + right, vec.at(place + 1), sum);
        //なしの場合、今考えている左辺はそのままにして、右辺を10倍して次の右辺に足して、次の演算を行う (vec, 1, 0, 12)→(vec, 2, 0, 123)
        ReFunc(vec, place + 1, left, right * 10 + vec.at(place + 1), sum);
    }
}



int main()
{
    string S;
    cin >> S;
    vector<int> vec(S.size());
    for (int i = 0; i < S.size(); i++)
    {
        vec.at(i) = S.at(i) - '0';
    }

    long long sum = 0;
    ReFunc(vec, 0, 0, vec.at(0), sum);
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
using namespace std;

typedef long long ll;

map<pair<int, int>, vector<pair<int, int>>> edg;
set<pair<int, int>> used;

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int p, q, c; cin >> p >> q >> c;
		--p; --q;
		pair<int, int> pp(p, c), qq(q, c);
		if (edg.count(pp) == 0) edg[pp] = vector<pair<int, int>>{{p, -1}};
		if (edg.count(qq) == 0) edg[qq] = vector<pair<int, int>>{{q, -1}};
		edg[pp].push_back(qq);
		edg[qq].push_back(pp);
		edg[{p, -1}].push_back(qq);
		edg[{q, -1}].push_back(pp);
	}

	priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que;
	que.push({0, {0, -1}});
	while (!que.empty()) {
		int d = que.top().first; pair<int, int> pos = que.top().second;
		que.pop();
		if (pos.first == n - 1 && pos.second == -1) {
			cout << d << endl;
			return 0;
		}
		if (used.count(pos) == 1) continue;
		used.insert(pos);
		vector<pair<int, int>> &v = edg[pos];
		if (pos.second == -1) {
			for (int i = 0; i < (int)v.size(); ++i) {
				if (used.count(v[i]) == 1)continue;
				que.push({d + 1, v[i]});
			}
		}
		else {
			for (int i = 0; i < (int)v.size(); ++i) {
				if (used.count(v[i]) == 1)continue;
				que.push({d, v[i]});
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

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

int N;
vector<ll> A;
vector<ll> SA;
vector<ll> DA;

int main(){
  cin >> N;
  SA.resize(N);
  DA.resize(N-1);

  int v;
  for(int i = 0; i < N; i++){
    cin >> v;
    A.push_back(v);
  }

  SA[0] = A[0];
  for(int i = 1; i < N; i++)
    SA[i] = A[i] + SA[i-1];

  //2分できればよいので、累積和の差を取る
  for(int i = 0; i < N-1; i++)
    DA[i] = abs((SA[N-1] - SA[i]) - SA[i]);
    
  sort(DA.begin(), DA.end());
  cout << DA[0] << endl;          //差は変化量＝費用
  return 0;

}
  

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
std::pair<ll, ll> ab[200005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n;

    for (int i = 0; i < 2 * n; ++i) {
        ll a;
        std::cin >> a;

        ab[i] = { a,(i < n ? 1 : -1) };
    }

    std::sort(ab, ab + 2 * n);

    ll ans = 1, sum = 0;
    for (int i = 0; i < 2 * n; ++i) {
        auto s = ab[i].second;
        if (sum == 0 || s * sum > 0) {
            sum += s;
        }
        else {
            ans = ans * std::abs(sum) % mod;
            sum += s;
        }
    }

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

    return 0;
}


Measured memory_bytes: 3328
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

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

fn main() {
    input! {
    mut n: u128
    }

    let mut tmp = 26;
    let mut l = 1;
    while n > tmp {
        n -= tmp;
        tmp *= 26;
        l += 1;
    }
    n -= 1;

    let mut vec = vec![];

    for _ in 0..l {
      let amari = n % 26;
      n = n / 26;
      vec.push((amari as u8 + b'a') as char);
    }

     println!("{}", vec.iter().rev().collect::<String>());
}


Measured memory_bytes: 2180
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        for (double i = 1; i <= 3500; i++) {
            for (double j = 1; j <= 3500; j++) {
                double k = n * i * j / (4 * i * j - n * i - n * j);
                if (k > 0 && k % 1 == 0) {
                    System.out.println((long)i + " " + (long)j + " " + (long)k);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 23764
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        System.out.println(N % s(N) == 0 ? "Yes" : "No");
    }

    private static int s(int n) {
        int s = 0;
        while (n > 0) {
            s += n % 10;
            n /= 10;
        }
        return s;
    }
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void){
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define $ system("pause")
#define MOD ll(1e9 + 7)
#define MAXN 100010
#define inf (ll)1e18

template<typename T> inline T smin(T &a, const T &b) { return a > b ? a = b : a; }
template<typename T> inline T smax(T &a, const T &b) { return a < b ? a = b : a; }
inline void add(ll &l, const ll &r) { l = (l + r) % MOD; }
ll gcd(ll v, ll u) { return u ? gcd(u, v % u) : v; }
ll po(ll v, ll u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; }

int n, arr[MAXN];
map<int, int> mp;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		mp[arr[i]] = i;
	}
	int answer = 0;
	sort(arr, arr + n);
	for (int i = 0; i < n; i++)
		if ((i ^ mp[arr[i]]) & 1)
			answer++;
	cout << (answer >> 1) << '\n';
	//$;
	return 0;
}

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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  string s; cin >> s;
  for (auto c : s) if (c == '7') return cout << "Yes", 0;
  cout << "No";
}




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

long long a[300002], A[300002], B[300002];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	priority_queue<long long> pq;
	long long sum = 0;
	for(int i = 0; i < 3*n; i++){
		cin >> a[i];
		pq.push(-a[i]);
		sum += a[i];
		if(n <= i){
			sum += pq.top();
			pq.pop();
		}
		A[i] = sum;
	}
	sum = 0;
	priority_queue<long long> pq2;
	for(int i = 3*n-1; i >= 0; i--){
		pq2.push(a[i]);
		sum += a[i];
		if(i < 2*n){
			sum -= pq2.top();
			pq2.pop();
		}
		B[i] = sum;
	}
	long long ans = -LLONG_MAX;
	for(int i = n; i <= 2*n; i++){
		ans = max(ans, A[i-1] - B[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9076
/******************************************
* AUTHOR : ARPIT *
* NICK : arpitfalcon *
* INSTITUTION : BIT MESRA *
* Ab m game m hu. *
******************************************/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 -
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vin                    \
    ll n;                      \
    cin >> n;                  \
    vector<ll> x(n);           \
    for (ll i = 0; i < n; i++) \
    cin >> x[i]
#define vout                   \
    for (ll i = 0; i < n; i++) \
    cout << x[i] << " "
#define T     \
    ll t = 1; \
    cin >> t; \
    while (t--)
#define ain                    \
    ll n, k;                   \
    cin >> n >> k;             \
    ll a[n];                   \
    for (ll z = 0; z < n; z++) \
    cin >> a[z]
#define aout                   \
    for (ll i = 0; i < n; i++) \
    cout << a[i] << " "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define max4(a, b, c, d) max(a, max3(b, c, d))
#define min4(a, b, c, d) min(a, min3(b, c, d))
#define blink                \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI = 3.141592653589793238463;

#define forn(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define for1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define forr(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))

/*
__builtin_ffs(x)
  Number of set bits: __builtin_popcount(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
*/

int main()
{
    blink
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    // your code goes here
    int n;
    cin >> n;
    vector<long long int> data(n);
    for (int i = 0; i < n; i++)
    {
        cin >> data[i];
    }

    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        while ((data[i] & 1) == 0)
        {
            data[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut even = true;
    for a in aa {
        if a%2!=0 {
            even = false;
            break;
        }
    }
    println!("{}", if even { "second" } else { "first" });
}


Measured memory_bytes: 4352
import bisect
n,a,b=map(int,input().split())
t=set([])
for i in range(n):
    t.add(int(input()))
t=list(t)
t.sort()
ai=bisect.bisect_left(t,a)
bi=bisect.bisect_left(t,b)
print(len(t)-(bi-ai))


Measured memory_bytes: 38256
A, B, C = map(int, input().split())
if (A * B * C) % 2 == 0:
    ans = 0
    print(ans)
else:
    ans = float('inf')
    V = A*B*C
    AB = A*B
    BC = B*C
    CA = C*A
    ans = min(ans, abs((A//2)*BC - ((A//2) + 1)*BC))
    ans = min(ans, abs((B//2)*CA - ((B//2) + 1)*CA))
    ans = min(ans, abs((C//2)*AB - ((C//2) + 1)*AB))
    print(ans)


Measured memory_bytes: 3064
#include <cstdio>

char getch(FILE *fin) {
  char ch = fgetc(fin);
  while(ch == ' ' || ch == '\n')
    ch = fgetc(fin);
  return ch;
}

char s1[52], s2[52];

bool vert(int i) {
  return s1[i] == s2[i];
}

const int MOD = 1000000007;

int main() {
  int n, rez;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i)
    s1[i] = getch(stdin);
  for(int i = 0; i < n; ++i)
    s2[i] = getch(stdin);

  int i;
  if(vert(0)) {
    rez = 3;
    i = 1;
  } else {
    rez = 6;
    i = 2;
  }
  while(i < n) {
    bool a, b;
    a = vert(i);
    b = vert(i - 1);
    if(a && b) {
      rez = rez * 2 % MOD;
      ++i;
    } else if(a)
      ++i;
    else if(b) {
      rez = rez * 2 % MOD;
      i += 2;
    } else {
      rez = (long long)rez * 3 % MOD;
      i += 2;
    }
  }
  printf("%d", rez);
  return 0;
}

Measured memory_bytes: 128
N=input()
ans=0

def f(x):
    result=""
    while x>=1:
        result+=str(x%3)
        x=int(x/3)
    result=result[::-1]
    return(result)

for M in range(len(N)+1):
    for n in range(3**M-1):
        number=f(n).zfill(M)
        if number.count("0")==0 or number.count("1")==0 or number.count("2")==0:
            pass
        else:
            number753=""
            for k in range(len(number)):
                if number[k]=="0":
                    number753+="3"
                elif number[k]=="1":
                    number753+="5"
                else:
                    number753+="7"
            if int(number753)>int(N):
                pass
            else:
                ans+=1

print(ans)

Measured memory_bytes: 3188
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		bool[] h=new bool[s[1]+1];
		int g=0;
		uf u=new uf(s[0]+s[1]+1);
		for(int i=0;i<s[0];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			for(int j=1;j<=q[0];j++){
				u.union(i,q[j]+s[0]);
				if(!h[q[j]]){
					h[q[j]]=true;
					g++;
				}
			}
		}
		Console.WriteLine("{0}",u.total(0)-g==s[0]?"YES":"NO");
	}
}
public class uf{
	private int[] arr;
	private int[] hi;
	public uf(int n){
		arr=new int[n];
		hi=new int[n];
		for(int i=0;i<n;i++){arr[i]=-1;}
	}
	public void union(int a,int b){
		a=root(a);
		b=root(b);
		if(a!=b){
			if(hi[a]<hi[b]){
				int v=b;
				b=a;
				a=v;
			}
			arr[a]+=arr[b];
			hi[a]=Math.Max(hi[a],hi[b]+1);
			arr[b]=a;
		}
	}
	public bool same(int a,int b){return root(a)==root(b);}
	public int total(int a){return -arr[root(a)];}
	private int root(int a){return arr[a]<0?a:arr[a]=root(arr[a]);}
}

Measured memory_bytes: 23896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var a = ReadLine().Split().Select(long.Parse).ToArray();
        var b = new long[2, n];
        var sum = new long[2, n];
        var count = new long[2];
        for(int i = 0; i < n; i++)
        {
            b[0, i] = a[i];
            b[1, i] = -a[i];
        }
        for(int i = 0; i < 2; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(j == 0)
                    sum[i, j] = b[i, j];
                else
                    sum[i, j] = b[i, j] + sum[i, j - 1];
                if(j % 2 == 0)
                {
                    if(sum[i, j] <= 0)
                    {
                        var temp = 1 - sum[i, j];
                        b[i, j] += temp;
                        count[i] += temp;
                        if(j == 0)
                            sum[i, j] = b[i, j];
                        else
                            sum[i, j] = b[i, j] + sum[i, j - 1];
                    }
                }
                else
                {
                    if(sum[i, j] >= 0)
                    {
                        var temp = -1 - sum[i, j];
                        b[i, j] += temp;
                        count[i] += Abs(temp);
                        if(j == 0)
                            sum[i, j] = b[i, j];
                        else
                            sum[i, j] = b[i, j] + sum[i, j - 1];
                    }
                }
            }
        }
        WriteLine(count.Min());
    }
}


Measured memory_bytes: 36940
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"

int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<int>ns(N);
		for (int i = 0; i < N; ++i) {
			cin >> ns[i];
		}
		ns.push_back(0);
		vector<int>scores;
		for (int i = 0; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) {
				scores.push_back(ns[i] + ns[j]);
			}
		}
		sort(scores.begin(), scores.end());
		scores.erase(unique(scores.begin(), scores.end()), scores.end());
		int ans = 0;
		for (auto it = scores.begin(); it != scores.end(); it++) {
			int rest = M - *it;
			auto jt = upper_bound(scores.begin(), scores.end(), rest);
			if (jt != scores.begin()) {
				ans = max(ans, M-(rest - *prev(jt)));
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10744
def solve(n):
    ret=""
    i=0
    while True:
        if i%2==1 and n%2==1: #奇数ビットが1のとき
            n+=2
        ret+=str(n%2)
        n//=2
        if n==0:
            break
        i+=1
    return ret[-1::-1] #逆順に結合されているので反転

n=int(input())
if n==0:
    print(0)
elif n<0: #負数は左ビットシフトして一文字落とす
    print(solve(n*(-2))[:-1])
else:
    print(solve(n))


Measured memory_bytes: 38512
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(w_max+1, 0)
items.each do |iw, iv|
  prev = dp.dup
  (iw..w_max).each do |w|
    v = prev[w - iw] + iv
    dp[w] = v if prev[w] < v
  end
end
puts dp.last


Measured memory_bytes: 68220
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($A,$B,$M) = explode(" ",trim(fgets(STDIN)));
$a = array_map('intval',explode(" ",trim(fgets(STDIN))));
$b = array_map('intval',explode(" ",trim(fgets(STDIN))));

//そのまま買った時の最小値
$least = min($a)+min($b);
for($i=0;$i<$M;$i++) {
  list($x,$y,$c) = array_map('intval',explode(" ",trim(fgets(STDIN))));
  //割引券を使った時
  $x--;
  $y--;
  $least = min($a[$x]+$b[$y]-$c,$least);
}
printf("%d\n",$least);


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

#define max_n 100001
 
int main(){
    int n,k;
    cin>>n>>k;
    
    vector<int> a(max_n);
    rep(i,n)cin>>a[i];
    bool dp[max_n];
    rep(i,k+1)dp[i]=false;

    rep(i,k+1){
        rep(j,n){
            if(i>=a[j])dp[i] |= !dp[i-a[j]];
        }
    }
    string ans=(dp[k])?"First":"Second";
    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>

int main(void) {
    std::string fake_S, S;
    std::cin >> fake_S >> S;
    std::cout << "A" << S[0] << "C" << std::endl;
    return 0;
}

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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [u64; n],
    }
    let mut dp = a.clone();
    let mut d = std::collections::VecDeque::new();
    for k in 1..k {
        d.clear();
        d.push_back((k - 1, dp[k - 1]));
        for (i, (a, dp)) in a[k..].iter().zip(dp[k..].iter_mut()).enumerate() {
            let i = i + k;
            if d.front().unwrap().0 + m + 1 == i {
                d.pop_front();
            }
            let next = d.front().unwrap().1 + ((k + 1) as u64) * *a;
            while let Some((j, v)) = d.pop_back() {
                if v > *dp {
                    d.push_back((j, v));
                    break;
                }
            }
            d.push_back((i, *dp));
            *dp = next;
        }
    }
    let ans = dp[(k - 1)..].iter().max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int count = 1;
        for(int i = 0;i < 2;i++){
            //System.out.println("i:" + i + "hikaku:" + N.substring(i,i+1));
            //System.out.println("j:" + j + "hikaku:" + N.substring(j,j+1));
            if(N.charAt(i) == N.charAt(i+1) && N.charAt(i+1) == N.charAt(i+2)){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
n = int(input())
min_sum = 99999999999999
if n == 2 :
  print (2)
  exit()
for i in range (1, n - 1):
  first = i
  second = n - i
  first_sum = 0
  second_sum = 0
  while first > 0 :
    last_digit_first = first % 10
    first = first // 10
    first_sum += last_digit_first
    
  while second > 0 :
    last_digit_second = second % 10
    second = second // 10
    second_sum += last_digit_second
  
  if first_sum + second_sum <= min_sum :
    min_sum = first_sum + second_sum
print(min_sum)
  

Measured memory_bytes: 9008
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int nN, nM;
	cin >> nN >> nM;
	int nTemp = 0;
	int nArr[100][100] = {}; //all 0
	int nB[100] = {};
	int nSum = 0;
	for (size_t i = 0; i < nN; ++i)
	{
		for (size_t j = 0; j < nM; ++j)
		{
			cin >> nTemp;
			nArr[i][j] = nTemp;
		}
	}

	for (size_t i = 0; i < nM; i++)
	{
		cin >> nTemp;
		nB[i] = nTemp;
	}
	for (size_t i = 0; i < nN; i++)
	{
		nSum = 0;
		for (size_t j = 0; j < nM; j++)
		{
			nSum += nArr[i][j] * nB[j];
		}
		cout << nSum << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
const int INF = 1001001001;

int main()
{
    int w,h,n; cin >> w >> h >> n;
    int x1=0,x2=w,y1=0,y2=h;
    rep(i,n){
        int xi,yi,a; cin >> xi >> yi >> a;
        if(a==1) x1 = max(x1,xi);
        if(a==2) x2 = min(x2,xi);
        if(a==3) y1 = max(y1,yi);
        if(a==4) y2 = min(y2,yi);
    }
    if(x2-x1 <= 0 || y2-y1 <= 0) cout << 0 << endl;
    else cout << (x2-x1) * (y2-y1) << endl;
}

/*
Ctrl+@
g++ a.cpp
./a.out
*/


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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);

//int main(void) {
//	int  R;
//	double tmp;
//
//	i_cin(R);
//
//	f_cout((double)R * 3.14*2.0);
//
//	return 0;
//}
static long  a[200000];

int main(void) {
	int N,i;
	int A[200001];

	int cnt = 0;


    i_cin(N);
	i_cins(N-1, A);

	for (i = 0; i < N-1; i++)
		a[A[i]-1]++;
	
	
	for (i = 0; i < N; i++) {
		l_cout(a[i]);
	}
	
	return 0;
}
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 3996
#include <iostream>
using namespace std;
int N,T[10010],inf = 1e9;
int dp[2][10010][2] = {};
//t番目まで見て，0の人がj個，最後に振り分けたのがk
int main(){
    cin >> N;
    for(int i=1;i<N;i++){
        cin >> T[i];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<2;j++){
            dp[0][i][j] = inf;
            dp[1][i][j] = inf;
        }
    }
    dp[1][0][0] = 0;
    dp[1][0][1] = 0;
    for(int t=1;t<=N;t++){
        for(int j=0;j<=N/2;j++){
            if(j>0) dp[1-t%2][j][0] = min(dp[1-t%2][j][0],dp[t%2][j-1][0]);
            dp[1-t%2][j][1] = min(dp[1-t%2][j][1],dp[t%2][j][1]);
            if(j>0){
 //               dp[1-t%2][j][0] = min(dp[1-t%2][j][0],dp[t%2][j-1][0]+T[t]);
                dp[1-t%2][j][1] = min(dp[1-t%2][j][1],dp[t%2][j-1][0]+T[t]);
            }
            dp[1-t%2][j][0] = min(dp[1-t%2][j][0],dp[t%2][j][1]+T[t]);
   //         dp[1-t%2][j][1] = min(dp[1-t%2][j][1],dp[t%2][j][1]+T[t]);
        }
        for(int j=0;j<=N/2;j++){
            dp[t%2][j][0] = inf;
            dp[t%2][j][1] = inf;
        }
    }
    cout << min(dp[1][N/2][0],dp[1][N/2][1]) << endl;
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int x,n; cin>>x>>n;
  vector<int> p(n);
  for(auto &i:p) cin>>i;
  sort(p.begin(),p.end());
  int ans{};
  for(int i=0; i<=101; i++){
    auto it = lower_bound(p.begin(),p.end(),i);
    if(it==p.end()||*it!=i){
      if(abs(i-x)<abs(ans-x)) ans = i;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3632
X,K,D=map(int,input().split())
t=abs(X)//D
if X==0:
  if K%2==0:
    print(0)
  else:
    print(D)
elif t>=K:
  print(abs(X)-D*K)
else:
  m=abs(X)-t*D
  n=abs(m-D)
  if (K-t)%2==0:
    print(m)
  else:
    print(n)

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

int main()
{
    int A,B,C,X,sum=0;
    cin >> A >> B >> C >> X;
    for(int i= 0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(500*i+100*j+k*50 == X){
                    sum++;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int F[105][10];
int P[105][11];
bool ff[10]={0};
long long mm=-1e9;
int n;
void dfs(int x,int y)
{
    if(x==10)
    {
        if(y==0)
            return;
        int t[105]={0};
        for(int i=0;i<10;i++)
            if(ff[i]==1)
        {
            for(int j=0;j<n;j++)
                if(F[j][i]==1)
                        t[j]++;
        }
        long long sum=0;
        for(int i=0;i<n;i++)
            sum+=P[i][t[i]];
        mm=max(sum,mm);
        return ;
    }
    ff[x]=1;
    dfs(x+1,y+1);
    ff[x]=0;
    dfs(x+1,y);
    return ;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        for(int j=0;j<10;j++)
            scanf("%d",&F[i][j]);
    for(int i=0;i<n;i++)
        for(int j=0;j<11;j++)
            scanf("%d",&P[i][j]);
    dfs(0,0);
    cout<<mm<<endl;
}


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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

const int mod = 1e9+7;

int N;
auto dp = vectors(111, 9, 9, 9, -1); // dp[i][x][y][z]: i文字目までみたとき、iの3文字前がx、2文字前がy、1文字前がzのとき、AGC文字列以外の組み合わせの数

// 渡されたリストがAGCになるかの判定
bool isAGC(vector<int> C) {
  return C[0] == 0 and C[1] == 1 and C[2] == 2;
}

int rec(int idx, int c3, int c2, int c1) {
  if (idx >= N) {
    return !isAGC({c3, c2, c1});
  }

  if (dp[idx][c3][c2][c1] != -1) {
    return dp[idx][c3][c2][c1];
  }

  int ret = 0;

  for (int now = 0; now < 4; now++) {
    vector<int> t = {c3, c2, c1, now};
    bool ok = true;

    // tがAGC文字列になるかを判定する
    if (isAGC({c3, c2, c1}) or isAGC({c2, c1, now})) {
      ok = false;
    }

    // tをスワップしてAGC文字列になるかを判定する
    for (int i = 0; i < 3; i++) {
      vector<int> tt = t;
      swap(tt[i], tt[i+1]);
      if (isAGC({tt[0], tt[1], tt[2]}) or isAGC({tt[1], tt[2], tt[3]})) {
        ok = false;
      }
    }

    // tがAGC文字列にならないなら遷移させる
    if (ok) {
      Add(ret, rec(idx + 1, c2, c1, now));
    }
  }

  return dp[idx][c3][c2][c1] = ret;;
}

signed main() {
  cin >> N;

  int ans = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        if (i == 0 and j == 1 and k == 2) continue;
        if (i == 0 and j == 2 and k == 1) continue;
        if (i == 1 and j == 0 and k == 2) continue;
        Add(ans, rec(3, i, j, k));
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <unordered_set>
#include <stack>
#include <algorithm>
#include <queue>
#include <ctime>
#include <iomanip>
#include <tuple>
#include <functional>
#include <map> 
#include <numeric> 
#include <math.h>

using namespace std;


#define ll long long
#define pi pair<int, int>
#define vi vector<int>
#define vp vector<pi>
#define msa(A, a, n) memset(A, a, n*sizeof(A))
#define msv(A, a) fill(A.begin(), A.end(), a);
#define msc(A, n) memset(A, '\0', n)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
#define pern(i, b) per(i, b - 1, 0)
#define repn(i, b) rep(i, 0, b)
#define repe(i, a, b) for(int i = a; i <= b; i++)
#define repen(i, b) repe(i, 1, b)
#define fast ios_base::sync_with_stdio();cin.tie(0);
#define endl "\n"
//#define MYDEBUG 

void my_return(int code)
{
#ifdef MYDEBUG
	std::cout << "\n\nTime = " << fixed << std::setprecision(3) << double(clock()) / CLOCKS_PER_SEC << endl;
#endif
	exit(code);
}

int main()
{
	fast
#ifdef MYDEBUG
		freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	double d, t, s;
	cin >> d >> t >> s;
	cout << (((d / s) <= t) ? "Yes" : "No");


	my_return(0);
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<set>

std::string RS(std::string str){
	std::string result;
	for(int i=str.length()-1;i>=0;i--){
		result+=str[i];
	}
	return result;
}

int main(){
	int m;
	std::cin>>m;
	for(int ii=0;ii<m;ii++){
		std::string str;
		std::cin>>str;
		std::set<std::string> strs;
		for(int i=1;i<str.length();i++){
			std::string sf=str.substr(0,i);
			std::string sl=str.substr(i);
			//std::cout<<sf<<" "<<sl<<std::endl;
			strs.insert(sf+sl);
			strs.insert(RS(sf)+sl);
			strs.insert(sf+RS(sl));
			strs.insert(RS(sf)+RS(sl));

			strs.insert(sl+sf);
			strs.insert(RS(sl)+sf);
			strs.insert(sl+RS(sf));
			strs.insert(RS(sl)+RS(sf));
		}
		std::cout<<strs.size()<<std::endl;;
	}
}

Measured memory_bytes: 1300
n=int(raw_input())
s=[int(raw_input()) for _ in xrange(n)]
c=[]
for i in xrange(n):
    if s[i]%10!=0:
        c.append(s[i])
if sum(s)%10!=0:
    print sum(s)
else:
    if len(c)>0:
        print sum(s)-min(c)
    else:
        print 0


Measured memory_bytes: 2568