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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n, k;cin >> n >> k;
	ll sum = 0;
	vector<ll> v(n);
	REP(i, n){
		cin >> v[i];
		sum += v[i];
	}

	sort(ALL(v), greater<ll>());
	REP(i, min(k, n)){
		sum -= v[i];
	}

	cout << sum << endl;

	return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll N, A, B;

	cin >> N >> A >> B;

	ll rem = N - B - A + 1;
	if( rem < 0 || rem > (B-1) * (A-1) ){
		cout << -1 << endl;
		return 0;
	}

	int pos = N;
	rep(i,B-1){
		if(rem > 0){
			vector<int> out;
			rep(i,A-1) if(rem > 0){
				out.push_back( pos-- );
				rem--;
			}
			out.push_back( pos-- );
			reverse(all(out));
			for(auto t: out) cout << t << " ";
		}else{
			cout << pos-- << " ";
		}
	}
	rep(i,A) cout << i+1 << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 2208
using System;
using System.Linq;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToList();

            var over3200 = a.Count(x => x >= 3200);
            var colorList = a.Where(x => x < 3200).Select(x => x / 400).Distinct().ToList();

            int minAns, maxAns;

            if (over3200 == n)
            {
                minAns = 1;
                maxAns = over3200;
            }
            else
            {
                minAns = colorList.Count();
                maxAns = minAns + over3200;

            }


            Console.WriteLine($"{minAns} {maxAns}");
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string s; cin >> s;

  string result = "YES";
  int e = s.length()-1;
  while(e>=0) {
    if (e>=4&&s.substr(e-4, 5) == "dream") { e-=5; continue; }
    if (e>=6&&s.substr(e-6, 7) == "dreamer") { e-=7; continue; }
    if (e>=4&&s.substr(e-4, 5) == "erase") { e-=5; continue; }
    if (e>=5&&s.substr(e-5, 6) == "eraser") { e-=6; continue; }
    result = "NO";
    break;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a<=b && a<=c)
    {
        if(b<=c) cout<<a<<" "<<b<<" "<<c;
        else cout<<a<<" "<<c<<" "<<b;
    }
    else
    if(b<=a && b<=c)
    {
        if(a<=c) cout<<b<<" "<<a<<" "<<c;
        else cout<<b<<" "<<c<<" "<<a;
    }
    else
    if(c<=a && c<=b)
    {
        if(a<=b) cout<<c<<" "<<a<<" "<<b;
        else cout<<c<<" "<<b<<" "<<a;
    }
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	string str;
	cin >> str;

	int count = 0;
	REP(i, n - 1)
	{
		count += str[i] == str[i + 1] ? 1 : 0;
	}
	REP(i, k)
	{
		count += 2;
		if (count > n - 1)
		{
			count = n - 1;
			break;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

int A[200005];

int main() {
  int n;
  S(n);
  rep(i,0,n) {
    S(A[i]);
  }
  sort(A,A+n);
  reverse(A,A+n);
  LL ans = -A[0];
  int j = 0;
  rep(i,0,n) {
    ans += A[j];
    if(i&1) j++;
  }
  cout << ans << "\n";
  return 0;
}


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

int main() {
int N,K;
cin>>N>>K;
int x=1;
for(int i=0 ; i<N ; i++){
if(x*2<x+K){
x=x*2;
}
else{
x+=K;
}
}
cout<<x<<endl;
}

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


int main() {
  string s;
  int k;
  cin >> s >> k;
  int i = 0, sz = s.size();
  while(k>0&&i<sz) {
    int x = 'z' -s[i] + 1;
    if(x<=k&&x<26) {
      s[i] = 'a';
      k -= x;
    }
    i++;
  }
  // if(k>0) s[sz-1] = (char)(s[sz-1]+k);
  s[sz-1] += k%26;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3772
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char a[20], b[20], c[20];
    cin >> a >> b >> c;
    char d = 'A' - 'a';
    cout << (char)(a[0] + d) << (char)(b[0] + d) << (char)(c[0] + d) << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
ans = 0

for i in range(1,n-1):
    if p[i-1] <= p[i] and p[i] <= p[i+1]:
        ans += 1
    elif p[i+1] <= p[i] and p[i] <= p[i-1]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
S = input()
T = input()
ans = len(T)
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        if S[i:i+len(T)][j:j+1] != T[j:j+1]:
            count += 1
    ans = min(count,ans)
    
print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    ll ans = 1;
    vector<ll> A(N);
    Rep (i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    if (A[0] == 0) {
        cout << 0 << "\n";
        return 0;
    }
    Rep (i, N) {
        if (ans > 1000000000000000000 / A[i]) {
            cout << -1 << "\n";
            return 0;
        }
        ans *= A[i];
    }

    if (ans > 1000000000000000000) {
        cout << -1 << "\n";
        return 0;
    }

    cout << (ll)ans << endl;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll k, n;
    cin >> k >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll ans = k - (a[0]+k - a[n-1]);
    rep(i, n-1) chmin(ans, k - (a[i+1] -a[i]));
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    
    vector<ll> memo(n+2,0);
    
    for (int i = 0; i < n-1; i++) {
        ll t;
        std::cin >> t;
        memo[t]++;
    }
    for (int i = 0; i < n; i++) {
        std::cout << memo[i+1] << std::endl;
    }
}



Measured memory_bytes: 4844
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn=1, Kr=1, Knr=1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



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

	if (K == 1) cout << 0;
	else
	{
		cout << N - K;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
int pre[maxn],f[maxn+5];
int Find(int x) {
	if(pre[x]==x)
		return x;
	int ret=Find(pre[x]);
	f[x]=f[x]+f[pre[x]];
	return pre[x]=ret;
}
int main() {
	int n, m;
	bool flag=true;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		pre[i]=i;
	for(int i=1;i<=m;i++) {
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		if(flag) {
			if(Find(l)==Find(r)) {
				if(f[r]<=f[l]) {
					int p=f[l]-f[r];
					if(p!=d)
						flag=false;
				}
				else
					flag=false;
			}
			else {
				int k=Find(l);
				pre[k]=l;
				f[k]=-f[l];
				pre[l]=r;
				f[l]=d;
			}
		}
	}
	if(flag)
		puts("Yes");
	else
		puts("No");
}

Measured memory_bytes: 1024
#binary exponentiation for 2^big number -1
#sum of n choose. ... 2^n -1
# how to compute n choose a
# euler's quotient theorem
# special case fermats little theoreom


#n kinds of flowers, 1 of each kind
# choose 1 more of each to make bouquet
# a b, total num of flowers cannot be a or b
# how many diff ouquets can she make?
# find the count modulo (10^9 + 7)

#two bouquets are considered different

# (x^y)%p
def powerMod(x,y,p):
    #initialize result
    res = 1
    #update x if it is more than or equal to p
    x = x%p
    
    while (y>0):
        #if y is odd, multiply x with result
        if ((y&1)==1):
            res = (res*x)%p
        
        #y must be even now
        y = y >> 1 #y = y/2
        x = (x*x)%p
    return res

def power(x,y):
    #initialize result
    res = 1
    while (y>0):
        #if y is odd, multiple x with result
        if((y&1)==1):
            res = res*x
        
        #y is even
        y = y >> 1 #divide y by 2
        x = x*x
    return res


input = [int(x) for x in input().split()]
numFlowers = input[0]
a = input[1]
b = input[2]

tenToNine = power(10,9)
allchoices = powerMod(2,numFlowers,tenToNine+7)-1

#compute n choose k in O(k) time and O(1) space
def binomial(n,k):
    #since C(n,k) = C(n,n-k)
    if(k>n-k):
        k = n=k
    
    #initialize result
    res = 1
    #calculate value of simplified n choose k expansion
    for i in range(k):
        res = res*(n-i)
        res = res/ (i+1)
    return res

aX = 1
aY = 1

#need to compute x and y for a and b, clearly separate them
for i in range(a):
    aX = aX*(numFlowers-i)%(tenToNine+7)
    aY = aY*(i+1)%(tenToNine+7)

bX = 1
bY = 1

#need to compute x and y for a and b, clearly separate them
for i in range(b):
    bX = bX*(numFlowers-i)%(tenToNine+7)
    bY = bY*(i+1)%(tenToNine+7)

#subtract and we're done

# countA = aX*powerMod(aY,tenToNine+7-2,tenToNine+7)
# countB = bX*powerMod(bY,tenToNine+7-2,tenToNine+7)
countA = aX*powerMod(aY,tenToNine+7-2,tenToNine+7)
countB = bX*powerMod(bY,tenToNine+7-2,tenToNine+7)
numBouquet = (allchoices-countA-countB)%(tenToNine+7)

print(numBouquet)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		Map<String,Integer> mp=new TreeMap<String,Integer>();
		for(int i=0;i<n;i++)
		{
			String p=sc.next();
			if(mp.containsKey(p))
			{
				mp.put(p,mp.get(p)+1);
			}
			else
			{
				mp.put(p,1);
			}
		}
	   Set<Map.Entry<String,Integer>> sp=mp.entrySet();
	   long flag1=0;
	   long flag2=0;
	   long flag3=0;
	   long flag4=0;
	   if(mp.get("AC")==null)
	   {
		   System.out.println("AC x "+"0");  
	   }
	   else
	   {
	   System.out.println("AC x "+mp.get("AC"));
	   }
	   if(mp.get("WA")==null)
	   {
		   System.out.println("WA x "+"0"); 
	   }
	   else
	   {
	   System.out.println("WA x "+mp.get("WA"));
	   }
	   if(mp.get("TLE")==null)
	   {
		   System.out.println("TLE x "+"0"); 
	   }
	   else
	   {
	   System.out.println("TLE x "+mp.get("TLE"));
	   }
	   if(mp.get("RE")==null)
	   {
		   System.out.println("RE x "+"0"); 
	   }
	   else
	   {
	   System.out.println("RE x "+mp.get("RE"));
	   }
	
	  /* for(Map.Entry<String,Integer> st:sp)
	   {
		     if(st.getKey().equals("AC"))
		     {
		    	 flag1=1;
		    	 System.out.println("AC x "+st.getValue());
		    	 continue;
		     }
		     if(st.getKey().equals("WA"))
		     {
		    	 flag2=1;
		    	 System.out.println("WA x "+st.getValue());
		    	 continue;
		     }
		     if(st.getKey().equals("TLE"))
		     {
		    	 flag3=1;
		    	 System.out.println("TLE x "+st.getValue());
		    	 continue;
		    	 
		     }
		     if(st.getKey().equals("RE"))
		     {
		    	 flag4=1;
		    	 System.out.println("RE x "+st.getValue());
		    	 continue;
		     }
	   }
	   if(flag1==0)
	   {
		   System.out.println("AC x "+"0"); 
	   }
	   if(flag2==0)
	   {
		   System.out.println("WA x "+"0"); 
	   }
	   if(flag3==0)
	   {
		   System.out.println("TLE x "+"0"); 
	   }
	   if(flag4==0)
	   {
		   System.out.println("RE x "+"0"); 
	   }
	   */
		
	}

}


Measured memory_bytes: 60060
#include<bits/stdc++.h>
#include<string>
using namespace std;
int x;
int findSum(vector<vector<int> > ans,vector<int> V,int s){
	if(s>ans.size())
	 return -1;
	int cnt=INT_MAX;
	int flag=0;
	for(int i=0;i<V.size();i++){
		if(V[i]<x)
		  flag=1;
	}
	if(flag==0)
	 return 0;
	if(s==ans.size())
	 return -1;
	for(int i=s;i<ans.size();i++){
		vector<int> temp=V;
		for(int j=1;j<ans[0].size();j++){
			temp[j-1]+=ans[i][j];
		}
		int cost=findSum(ans,temp,i+1);
		if(cost==-1)
		continue;
		if(cost>=0)
		cnt=min(cnt,cost+ans[i][0]);
	}
	return cnt==INT_MAX?-1:cnt;
}
int main(){
int n,m;
cin>>n>>m>>x;
vector<vector<int> > matrix(n,vector<int> (m+1,0));
for(int i=0;i<n;i++){
	for(int j=0;j<=m;j++){
		cin>>matrix[i][j];
	}
}
vector<int> V(m,0);
cout<<findSum(matrix,V,0)<<" ";
}


Measured memory_bytes: 3616
Array.prototype.aggregate = function(){
  	return this.reduce((a,b)=>(a[b]=(a[b]||0)+1)&&a,{});
 }
 
 
function Main(input){
var mod = 1000000007;


	input = input.split("\n");
  var N = ~~input[0];
  var S = input[1];
  
  S = S.split("").aggregate();
  
  var num = 1;
  
  for (var p in S) {
  	num *= (S[p] + 1);
    num %= mod;
  }
  
  return num - 1;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
3
baa
`);

Measured memory_bytes: 22088
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<usize> = sc.read::<String>().chars().map(|c| c.to_string().parse().unwrap()).collect();
    println!("{}", dfs(&s, 1, 0, s[0]));
}

fn dfs(s: &Vec<usize>, i: usize, a: usize, b: usize) -> usize {
    if s.len() == i {
        a + b
    } else {
        dfs(s, i + 1, a + b, s[i]) + dfs(s, i + 1, a, b * 10 + s[i])
    }
}


mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	bool flag = false;
	flag = flag || n%10 == 7;
	n /= 10;
	flag = flag || n%10 == 7;
	n /= 10;
	flag = flag || n%10 == 7;
	flag ? cout<<"Yes" : cout<<"No";
}


Measured memory_bytes: 3616
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X = int(input())

    y = X // 500
    X = X - y * 500
    z = X // 5
    print(y * 1000 + z * 5)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long left = 2 * (a * b + b * c + c * a);
    long right = a * a + b * b + c * c;
    if (c - a - b > 0 && left < right) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35820
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

#include <sstream>
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while(getline(ss, item, delim)) {
        if(!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

ll power10(int n) {
    ll ret = 1;
    rep(i, n) ret *= 10;
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<string> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> nums(N);
    rep(i, N) {
        auto ss = split(A[i], '.');
        if(ss.size() == 1) {
            nums[i] = stol(ss[0]) * 1000000000LL;
        } else {
            nums[i] = stol(ss[0]) * 1000000000LL +
                      stol(ss[1]) * (power10(9 - ss[1].size()));
        }
    }
    vector<pii> factors(N);
    rep(i, N) {
        int a = 0, b = 0;
        while(nums[i] % 2 == 0) {
            nums[i] /= 2;
            a++;
        }
        while(nums[i] % 5 == 0) {
            nums[i] /= 5;
            b++;
        }
        factors[i] = MP(a, b);
    }
    vector<vector<ll>> prod(100, vector<ll>(100));
    rep(i, N) { prod[factors[i].first][factors[i].second]++; }
    vector<vector<ll>> cum(101, vector<ll>(101));
    for(int i = 0; i < 100; i++) {
        for(int j = 0; j < 100; j++) {
            cum[i + 1][j + 1] =
                cum[i][j + 1] + cum[i + 1][j] - cum[i][j] + prod[i][j];
        }
    }
    ll res = 0;
    rep(i, N) {
        int a = max(0, 18 - factors[i].first),
            b = max(0, 18 - factors[i].second);
        res += cum[100][100] - cum[100][b] - cum[a][100] + cum[a][b];
        if(factors[i].first >= 9 && factors[i].second >= 9)
            res--;
    }
    cout << res / 2 << endl;
    return 0;
}

Measured memory_bytes: 12708
N = 5

def main(argv)
  n = gets.chomp.to_i
  
  a = [0] * N
  N.times{|i| a[i] = gets.chomp.to_i}
  
  puts (a.map{|x| (n + (x - 1)) / x}.max + 4).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll count = B / A;
    if (count > C) {
        cout << C << endl;
    } else {
        cout << count << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;
const int INF = 1e18;
void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size() - 1)
    {
        if (s[i] != s[i + 1])
            ans++;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 640
def place(N,T,A,H):
    a=18000
    n=0
    for i in range(N):
        ave=T-H[i]*0.006
        if(abs(a-A)>abs(ave-A)):
            a=ave
            n=i+1
        
    return n

N=int(input())
T,A=input().split()
H=[int(i) for i in input().split()]

print(place(N,int(T),int(A),H))

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

int main() {
	string s;
  	cin>>s;
  int ans=0;
  int ch=0;
  
  rep(i,s.size()){
    
  	if(s[i]=='A'){
    	ch++;
    }
    else if(s[i]=='C'){
    	ch++;  
    } 
    else if(s[i]=='G'){
    	ch++;    
    } 
    else if(s[i]=='T'){
    	ch++;      
    }

   else{
    	ch=0;
    }
    
    
    if(ans<ch){
      	ans=ch;
      }
    
    
  }
  

  cout<<ans<<endl;
  
  
}

Measured memory_bytes: 3612
a = [int(i) for i in input().split()]
if a[0] > a[1]:
    if (a[0] >= a[2] >= a[1]):
        print("Yes")
    else:
        print("No")
else:
    if (a[0] <= a[2] <= a[1]):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int con = 0, c = -1, d = 0;
	vector<int> p, a;
	
	cin>>N;
	
	p.resize(N);
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>p[i];
		a[i] = p[i];
	}
	
	sort(a.begin(), a.end());
	
	for(int i = 0; i < N; i++){
		if(a[i] != p[i]){
			con++;
			if(c == -1) c = i;
			d = i;
		}
	}
	
	if(con == 0)cout<<"YES"<<endl;
	else if(con >= 3) cout<<"NO"<<endl;
	else {
		swap(p[c],p[d]);
		con = 0;
		for(int i = 0; i < N; i++){
				if(a[i] != p[i]){
			con++;
		}
		}
		
		if(con == 0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n % 2 == 1) NO;
  else{
    if(s.substr(0,n/2) == s.substr(n/2,n/2)) YES;
    else NO;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  x[a].append(h[b-1])
  x[b].append(h[a-1])
count=0
for j in range(1,n+1):
  if x[j]==[]:
    count+=1
  else:
    if h[j-1]>max(x[j]):
      count+=1
print(count)

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int t[5 * maxn], lazy[5 * maxn];

int doit(int a, int b) {
    return min(a, b);
}

void build(int start, int end, int index = 1) {
    if (start == end) {
        t[index] = INT_MAX;
        return;
    }

    int mid = start + end >> 1;
    build(start, mid, index << 1);
    build(mid + 1, end, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void propagate(int start, int end, int index) {
    t[index] = lazy[index];
    if (start != end) {
        lazy[index << 1] = lazy[index];
        lazy[index << 1 | 1] = lazy[index];
    }
    lazy[index] = -1;
}

int query(int start, int end, int l, int r, int index = 1) {
    if (lazy[index] != -1)
        propagate(start, end, index);
    //Invalid range
    if (r < start or l > end)
        return INT_MAX;

    //In range
    if (l <= start and end <= r) {
        return t[index];
    }

    int mid = start + end >> 1;
    return doit(query(start, mid, l, r, index << 1), query(mid + 1, end, l, r, index << 1 | 1));
}

void pUpdate(int start, int end, int point, int val, int index = 1) {
    if (start == end) {
        t[index] += val;
        return;
    }

    int mid = start + end >> 1;
    if (point <= mid)
        pUpdate(start, mid, point, val, index << 1);
    else
        pUpdate(mid + 1, end, point, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void rangeUpdate(int start, int end, int l, int r, int val, int index) {
    if (lazy[index] != -1)
        propagate(start, end, index);
    if (l > end or r < start)
        return;

    if (l <= start and end <= r) {
        lazy[index] = val;
        propagate(start, end, index);
        return;
    }

    int mid = start + end >> 1;
    rangeUpdate(start, mid, l, r, val, index << 1);
    rangeUpdate(mid + 1, end, l, r, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

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

    build(0, n - 1, 1);
    memset(lazy, -1, sizeof lazy);

    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;

        if (a == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            rangeUpdate(0, n - 1, s, t, x, 1);
        } else {
            int s, t;
            cin >> s >> t;

            cout << query(0, n - 1, s, t, 1) << endl;
        }
    }
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 9104
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 105;
ll n, ans, open[N][10], p[N][15];
ll solve(ll x){
    ll a[N] = {};
    for(int i = 0; i < 10; i++){
        if(x & (1 << i)){
            for(int j = 0; j < n; j++){
                if(open[j][i]) a[j]++;
            }
        }
    }
    ll res = 0;
    for(int i = 0; i < n; i++){
        res += p[i][a[i]];
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++)
            cin >> open[i][j];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++)
            cin >> p[i][j];
    }
    ans = -1e18;
    for(int i = 1; i < (1 << 10); i++){
        ans = max(ans, solve(i));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
    cin >> x >> a >> b;
    if(b<=a){
        puts("delicious");
    }else if(b-a<=x){
        puts("safe");
    }else{
        puts("dangerous");
    }

    return 0;
}

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

int main() {
  string S,T,L;
  cin >> S >> T;
  L = S + T.at(T.size()-1);
  if ( L == T){
    cout << "Yes" <<endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n%10==n/10%10)puts("Bad");
	else if(n/10%10==n/100%10)puts("Bad");
	else if(n/100%10==n/1000%10)puts("Bad");
	else puts("Good");
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int x, mx = 999, i, len = s.size();
    for(i = 0; i <= len - 3; i++)
    {
        x = abs(100*(s[i] - '0') + 10*(s[i+1] - '0') + s[i+2] - '0' - 753);
        mx = min(x, mx);
    }
    printf("%d", mx);
}

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

int main()
{
  uint64_t N, K;
  std::cin >> N >> K;
  
  std::vector<uint64_t> h(N);
  for (uint64_t n = 0; n < N; ++n) {
    std::cin >> h[n];
  }
  
  std::sort(h.begin(), h.end());
  
  uint64_t min = 1e+9;
  for (uint64_t i = 0; i <= N - K; ++i) {
    min = std::min(h[i + (K - 1)] - h[i], min);
  }
  std::cout << min << std::endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>
#define reset(x,n) memset((x),(n),sizeof(x))
#define all(n) (n).begin(),(n).end()
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0);
ll dp[100005];
ll arr[100005];
int main(){
	IOS 
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	dp[1]=0;
	dp[2]=abs(arr[1]-arr[2]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-2]+abs(arr[i-2]-arr[i]),dp[i-1]+abs(arr[i-1]-arr[i]));
	}
	cout<<dp[n]<<'\n';
}


Measured memory_bytes: 1792
/**
 * Country Road
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int d = parseInt(br.readLine());
		for (int i = 0; i < d; i++) {
			line = br.readLine();
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int k = parseInt(line.substring(line.indexOf(' ') + 1));
			//
			line = br.readLine();
			StringTokenizer st = new StringTokenizer(line);
			//
			int max = parseInt(line.substring(line.lastIndexOf(' ') + 1));
			int min = parseInt(st.nextToken());
			int maxLength = max - min;
			//
			int[] count = new int[max + 1];
			int[] distance = new int[n - 1];
			int next;
			while (st.hasMoreTokens()) {
				next = parseInt(st.nextToken());
				count[next - min]++;
				min = next;
			}
			for (int j = count.length - 1, l = distance.length - 1; l >= 0; j--) {
				if (count[j] > 0) {
					distance[l] = j;
					count[j]--;
					j++;
					l--;
				}
			}
			for (int j = distance.length - 1; k > 1 && j >= 0; j--) {
				maxLength -= distance[j];
				k--;
			}
			System.out.println(maxLength);
		}
	} //end main
}

Measured memory_bytes: 92644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S[500005];
ll sum = 0;

void merge(int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	vector<ll> L, R;
	REP(i, n1)
	{
		L.push_back(S[left + i]);
	}
	REP(i, n2)
	{
		R.push_back(S[mid + i]);
	}
	L.push_back(INF); R.push_back(INF);
	int i = 0, j = 0;
	FOR(k, right, left)
	{
		++sum;
		if (L[i] <= R[j])
		{
			S[k] = L[i++];
		}
		else
		{
			S[k] = R[j++];
		}
	}
}

void mergeSort(int left, int right)
{
	if (left + 1 >= right)
	{
		return;
	}
	int mid = (left + right) / 2;
	mergeSort(left, mid);
	mergeSort(mid, right);
	merge(left, mid, right);
}

int main()
{
	int n;
	cin >> n;
	REP(i, n)
	{
		cin >> S[i];
	}
	mergeSort(0, n);
	cout << S[0];
	FOR(i, n, 1)
	{
		cout << " " << S[i];
	}
	cout << endl << sum << endl;
	return 0;
}


Measured memory_bytes: 11576
using System;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string x = Console.ReadLine();
            string[] y = x.Split();
            int a = int.Parse(y[0]);
            int b = int.Parse(y[1]);

            int cnt= 0;
            for (int i = a; i <= b; i++) {
                if (i % k == 0) {
                    cnt++;
                }
            }
            if (cnt != 0)
            {
                Console.WriteLine("OK");
            }
            else {
                Console.WriteLine("NG");
            }


        }
    }
}


Measured memory_bytes: 27552
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

void rotate(int a[], string str)
{
    for(auto itr = str.begin(); itr != str.end(); ++itr)
    {
        int tmp;
        switch (*itr) {
            case 'N':
                tmp = a[0];
                a[0] = a[1];
                a[1] = a[5];
                a[5] = a[4];
                a[4] = tmp;
                break;
            case 'S':
                tmp = a[0];
                a[0] = a[4];
                a[4] = a[5];
                a[5] = a[1];
                a[1] = tmp;
                break;
            case 'W':
                tmp = a[3];
                a[3] = a[0];
                a[0] = a[2];
                a[2] = a[5];
                a[5] = tmp;
                break;
            case 'E':
                tmp = a[2];
                a[2] = a[0];
                a[0] = a[3];
                a[3] = a[5];
                a[5] = tmp;
                break;
        }
    }
}

int main(void)
{
    int a[6], b[6];
    string str;
    for (int i = 0; i < 6; ++i)
        cin >> a[i];
    for (int i = 0; i < 6; ++i)
        cin >> b[i];

    bool flag;
    for (int i = 0; i < 6; ++i) {
        flag = false;
        for (int j = 0; j < 6; ++j) {
            if (a[i] == b[j]) {
                flag = true;
                break;
            }
        }
        if (flag==false)
            break;
    }

    if (flag == false) {
        cout << "No" << endl;
        return 0;
    }

    int t = b[0], f = b[1];

    if (t == a[5])
            rotate(a, "NN");
    else if (t == a[1])
            rotate(a, "N");
    else if (t == a[3])
            rotate(a, "E");
    else if (t == a[2])
            rotate(a, "W");
    else if (t == a[4])
            rotate(a, "S");

    if (f == a[3])
            rotate(a, "ESW");
    else if (f == a[2])
            rotate(a, "WSE");
    else if (f == a[4])
                rotate(a, "SENWSE");

    for (int i = 0; i < 6; ++i) {
        if (a[i] != b[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}







Measured memory_bytes: 3240
#include<stdio.h>
int main(){
  int n,i,a[45];
  scanf("%d",&n);
  a[0] = 1;
  a[1] = 1;
  for(i=2;i<=n;i++) a[i] = a[i-1]+a[i-2];
  printf("%d\n",a[n]);
  return (0);
}

Measured memory_bytes: 2744
import java.util.*;

public class Main {
    static int INF = 1001001009;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int n = sc.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = sc.nextInt();
            values[i] = sc.nextInt();
        }
        
        // dp[i][w]: 品物0~iまでなめた時のwダメージ与えられる最小コスト
        int[][] dp = new int[n + 1][W + 1];
        // 初期化
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                dp[i][w] = INF;
            }
        }
        // 0ダメージ与えられる最小のコストは0
        for (int i = 0; i <= n; i++) {
            dp[i][0] = 0;
        }
        
        // dp[i + 1][w] (品物iまでを使ったときの)wダメージ与えられる最小のコスト
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                // 品物iを選択できる(重量[i]がw以下)
                if (w - weights[i] >= 0) {
                    // 選択できる場合、選択する方/しない方の最善を選ぶ
                    // (選択するには品物"i"のダメージ[i]分少ないとこからなら遷移できる)
                    // (※個数制限なしなので自分(i)から遷移できる (ありならi-1から遷移))
                    dp[i + 1][w] = Math.min(dp[i + 1][w - weights[i]] + values[i], dp[i][w]);
                } else {
                    // 選択できない場合、ダメージ0から遷移する
                    dp[i + 1][w] = Math.min(dp[i + 1][0] + values[i], dp[i][w]);
                }
            }
        }
        // for (int i = 0; i < n+1; i++) {
        //     System.out.println(Arrays.toString(dp[i]));
        // }
        
        System.out.println(dp[n][W]);
    }
}

Measured memory_bytes: 86548
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    if(str == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;


    return 0;
}

Measured memory_bytes: 3624
#! /usr/bin/python
# -*- coding: utf-8 -*-

while True:
    (n, w) = map(int, raw_input().split())
    if n == 0: break

    vcnt = [0]*11
    vr = 0
    for i in range(n):
        v = int(raw_input())
        if v/w > vr:
            vr = v/w
        vcnt[v/w] += 1
    
    vmax = max(vcnt)
    ans = 0
    for i in range(11):
        ans += ((vr-i)/float(vr))*(vcnt[i]/float(vmax))

    print ans+0.01

Measured memory_bytes: 4256
import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

answer1 = []
for i in range(Q):
  ii = bisect.bisect_right(S, X[i])
  s1, s2 = ii - 1, ii % A
  d1, d2 = abs(X[i] - S[s1]), abs(X[i] - S[s2])
  
  jj1 = bisect.bisect_right(T, S[s1])
  t11, t12 = jj1 - 1, jj1 % B
  dd11, dd12 = abs(S[s1] - T[t11]), abs(S[s1] - T[t12])

  jj2 = bisect.bisect_right(T, S[s2])
  t21, t22 = jj2 - 1, jj2 % B
  dd21, dd22 = abs(S[s2] - T[t21]), abs(S[s2] - T[t22])
  
  answer1.append(min(d1 + min(dd11, dd12), d2 + min(dd21, dd22)))

S, T = T, S
A, B = B, A
answer2 = []
for i in range(Q):
  ii = bisect.bisect_right(S, X[i])
  s1, s2 = ii - 1, ii % A
  d1, d2 = abs(X[i] - S[s1]), abs(X[i] - S[s2])
  
  jj1 = bisect.bisect_right(T, S[s1])
  t11, t12 = jj1 - 1, jj1 % B
  dd11, dd12 = abs(S[s1] - T[t11]), abs(S[s1] - T[t12])

  jj2 = bisect.bisect_right(T, S[s2])
  t21, t22 = jj2 - 1, jj2 % B
  dd21, dd22 = abs(S[s2] - T[t21]), abs(S[s2] - T[t22])
  
  answer2.append(min(d1 + min(dd11, dd12), d2 + min(dd21, dd22)))

for i in range(Q):
  print(min(answer1[i], answer2[i]))

Measured memory_bytes: 115800
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	var a, b, c, d int
	a = int(s[0] - '0')
	b = int(s[1] - '0')
	c = int(s[2] - '0')
	d = int(s[3] - '0')

	for _, k1 := range []int{-1, 1} {
		for _, k2 := range []int{-1, 1} {
			for _, k3 := range []int{-1, 1} {
				if a+k1*b+k2*c+k3*d == 7 {
					op := map[int]string{-1: "-", 1: "+"}
					fmt.Print(a)
					fmt.Print(op[k1])
					fmt.Print(b)
					fmt.Print(op[k2])
					fmt.Print(c)
					fmt.Print(op[k3])
					fmt.Print(d)
					fmt.Println("=7")
					return
				}
			}
		}
	}
}


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

s = input()
res = 0
if( s == 'RRR'):
    res = 3
elif( s == 'SRR' or s == 'RRS'):
    res = 2
elif( s == 'SSS'):
    res = 0
else:
    res = 1

print(res)


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


int main() {
	//コマンド数→コマンド→insertとdeleteでは要素
	int q = 0;
	int x = 0;
	char com[20];

	list<int> List;

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> com;

		if (com[0] == 'i') {
			cin >> x;
			List.push_front(x);

		}
		else if (com[6] == 'F') {
			List.pop_front();
		}
		else if (com[6] == 'L') {
			List.pop_back();
		}
		else if (com[0] == 'd') {
			cin >> x;

			for (list<int>::iterator it = List.begin(); it != List.end(); it++) {
				if (*it == x) {
					List.erase(it);
					break; //超大事
				}
			}
		}
	}

	int i = 0;//空白作る用

	for (list<int>::iterator it = List.begin(); it != List.end(); it++) {
		if (i++) {
			cout << " ";
		}

		cout << *it;

	}

	cout << "\n";

	return 0;
}





Measured memory_bytes: 34328
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

int dp[1<<15+1][4];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	for(int i=1;i*i<=(1<<15);i++){
		for(int j=0;j<3;j++){
			if(j==0){
				dp[i*i][j]=1;
			}
			for(int k=1;k<=(1<<15);k++){
				if(k+i*i<=(1<<15)){
					dp[k+i*i][j+1]+=dp[k][j];
				}
			}
		}
	}
	int n;
	while(cin >> n,n){
		ll res=dp[n][0]+dp[n][1]+dp[n][2]+dp[n][3];
		cout << res << endl;
	}
}





Measured memory_bytes: 3696
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int n;
	cin >> n;
	vector< vector<int> >f(n, vector<int>(10,0));
	vector< vector<int> >p(n, vector<int>(11, 0));

	rep(i, 0, n) {
		rep(j, 0, 10) {
			cin >> f[i][j];
		}
	}
	rep(i, 0, n) {
		rep(j, 0, 11) {
			cin >> p[i][j];
		}
	}


	vector<int>ans;
	for (int bit= 1; bit < (1 << 10);bit++) {
		int temp = 0;
		rep(i, 0, n) { 
			int c = 0;
			rep(j, 0, 10){
				if ((bit & (1<<j))&&(f[i][j]==1)) {
					c++;
				}
			}
			temp += p[i][c];
		}
		ans.push_back(temp);
	}

	int a = ans[0];
	rep(i, 1, ans.size()) {
		a = max(a, ans[i]);
	}

	cout << a << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mn=1e5+10;
typedef long long ll;
int x,y,z;
struct node {
	ll a,b,c;
} d[mn];
ll sc,ans,l[mn],r[mn];
struct cmp {
	bool operator() (ll x,ll y) {
		return x>y;
	}
};
priority_queue<ll,vector<ll>,cmp> q,p;
bool cmp(node x,node y) {
	return x.a-x.b<y.a-y.b;
}
int main() {
	scanf("%d %d %d",&x,&y,&z);
	int n = x+y+z ;
	for (int i=1;i<=n;i++)
		scanf("%lld %lld %lld",&d[i].a,&d[i].b,&d[i].c);
	sort(d+1,d+(n+1),cmp);
	sc=0;
	for (int i=1;i<=n;i++) {
		d[i].a-=d[i].c;
		d[i].b-=d[i].c;
		sc+=d[i].c;
	}
	l[0]=0;
	int t;
	for (int i=1;i<=y;i++) {
		t=d[i].b;
		q.push(t);
		l[i]=l[i-1]+t;
	}
	for (int i=y+1;i<=n;i++) {
		if (d[i].b<=q.top()) {
			l[i]=l[i-1];
			continue;
		}
		t=d[i].b;
		q.push(t);
		l[i]=l[i-1]+t;
		l[i]-=q.top();
		q.pop();
	}
	r[x+y+z+1]=0;
	for (int i=n;i>y+z;i--) {
		t=d[i].a;
		p.push(t);
		r[i]=r[i+1]+t;
	}
	for (int i=y+z;i>=1;i--) {
		if (d[i].a<=p.top()) {
			r[i]=r[i+1];
			continue;
		}
		t=d[i].a;
		p.push(t);
		r[i]=r[i+1]+t;
		r[i]-=p.top();
		p.pop();
	}
	for (int i=y;i<=n-x;i++)
		if (i==y)
			ans=l[i]+r[i+1];
		else ans=max(ans,l[i]+r[i+1]);
	printf("%lld\n",ans+sc);
	return 0;
}


Measured memory_bytes: 5240