akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n; cin >> n;
  ll a[n];
  rep(i,0,n) cin >> a[i];
  ll arr[n];
  rep(i,0,n) arr[i]=1000;
  ll init=0;
  ll MAX=1000;
  for(int i=0; i<n; ++i){
    init = arr[i]/a[i];
    ll rem = arr[i]%a[i];
    for(int j=i+1; j<n; ++j){
      arr[j] = max(arr[j], rem+(init*a[j]));
      arr[j]=max(arr[j],arr[j-1]);
      MAX=max(MAX,arr[j]);
    }
    //rep(j,0,n) cout << arr[j] << " ";
    //cout << endl;
  }
  cout << MAX << endl;
}





Measured memory_bytes: 3608
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>
#include<queue>
#include<set>


#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}



bool comp(const pair<long long int, vector<int>> a, const pair<long long int, vector<int>> b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}
	else {
		return a.second < b.second;
	}

}

int main(){

	long long int n, m;
	cin >> n >> m;

	vector<int> ac(n,0);
	vector<int> wa(n,0);

	long long int ansAC = 0;
	long long int ansWA = 0;

	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p;
		cin >> s;

		if (s == "WA") {
			wa[p - 1]++;
		}
		else {
			if (ac[p - 1] == 0) {
				ansAC++;
				ac[p - 1] = 1;
				ansWA += wa[p - 1];
			}
		}

	}

	cout << ansAC << " " << ansWA << endl;



	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    long N;
    cin >> N;
    long ans = 0;
    if(N%2 == 0){
        long n = log10(N);
        ans += N/10;
        N /= 10;
        for(int i=0; i<10*n; i++){
            ans += N/5;
            N/=5;
        }
        cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int N,K;
   cin >> N >> K;
   vector<int> h(N);
   for (int i=0; i<N; i++){
       cin >> h.at(i);
   }

   int c = 0;
   for (int i=0; i<N; i++){
       if (h.at(i) >= K){
           c += 1;
       }
   }
   cout << c;
    return 0;
}

Measured memory_bytes: 640
import math
a,b,h,m=map(str, input().split())
h=float(h)
m=float(m)
a=float(a)
b=float(b)
mth=m*6
hth=30*h+m/2
th=math.pi*abs(mth-hth)/180
c=math.sqrt(a**2+b**2-2*a*b*math.cos(th))
print(c)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
int n;
  cin>>n;
  vector<int> a(n+1);
  a.at(0)=0;
  rep(i,n) cin>>a.at(i+1);
  int cnt =0;
  
  for(int i=1;i<n+1;i++){
      if(cnt==3) break;
     else if(a.at(i)==i) continue;
     else cnt ++;
  }
  
  if(cnt%2==0 ) cout <<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    boost;
    int n;cin>>n;
    string s;cin>>s;
    
    int rd=0;
    int wd=0;
    int rm =0 ;
    int wm = 0;
    for(int i =0 ; i < n ; i++){
        if(s[i]=='R')rm++;
        else wm++;
    }
    int ans = min(rm,wm);
    for(int i  = 0 ; i < n ; i ++ ){
        if(s[i] == 'R'){
            rd++;
            rm--;
        }else{
            wd++;
            wm--;
        }
    
    if(wd <= rm)    
        ans = min(ans , rm );
    else
        ans = min(ans,wd);
        
        
    }
    cout<<ans<<endl;
    
   
}

Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int NOE(){
    cout<<-1<<endl;
    return 0;
}

unordered_map<ll,ll> mas;
#define N 100010
vector<ll> g[N];
ll n,d[N],s[N];
void AddEdge(ll a,ll b){
    s[b]+=s[a];
    g[a].push_back(b);
    g[b].push_back(a);
}

class Judge{public:
    ll f[N],s[N];
    void dfs(ll x,ll bef){
	ll res=0,sum=1;
	for(auto y:g[x]){
	    if(y==bef)continue;
	    dfs(y,x);
	    res+=f[y];
	    sum+=s[y];
	}
	s[x]=sum;
	f[x]=res+sum-1;
    }
    bool Main(){
	dfs(0,-1);
	return d[0]==f[0];
    }
};

unordered_map<ll,ll> ans;
int main(){
    cin>>n;
    lol(i,n){
	cin>>d[i];
	s[i]=1;
	ans[d[i]]=i+1;
    }
    sort(d,d+n,greater<ll>());
    lol(i,n)mas[d[i]]=i;
    lol(i,n-1){
	ll to=d[i]+2*s[i]-n;
	if(d[i]<=to)return NOE();
	if(mas.find(to)==mas.end())return NOE();
	AddEdge(i,mas[to]);
    }
    Judge jd;
    if(jd.Main()==0)return NOE();
    lol(i,n){
	for(auto x:g[i]){
	    if(i<x)cout<<ans[d[i]]<<" "<<ans[d[x]]<<endl;
	}
    }
    return 0;
}


Measured memory_bytes: 22564
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N = 100;
int N, K;
int X[MAX_N];
int main(){
	scanf("%d", &N);
	scanf("%d", &K);
	for(int i = 0; i < N; ++i){
		scanf("%d", X + i);
	}
	int ans = 0;
	for(int i = 0; i < N; ++i){
		int tmp = min(X[i], K - X[i]);
		ans += tmp;
	}
	printf("%d\n", ans * 2);
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  char S[N];
  bool flag = false;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if(S[i]=='Y') flag=true;
  }
  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
int main(){
    string S; cin>>S;
    int N=S.size();
    ll ans=0;

    for(int bit=0; bit< (1<<(N-1)); bit++){
        ll tmp=0;
        for(int i=0; i<N-1; i++){
            tmp *= 10;
            tmp+= S[i]-'0';
            if(bit & (1 << i)){
                ans += tmp;
                tmp =0;
            }
        }
        tmp *= 10;
        tmp += S.back() - '0';
        ans += tmp;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)res=res*x%m;
		y>>=1;x=x*x%m;
	}
	return res;
}
int perm[1000001],inv[1000001];
void init_perm(){
	perm[0]=1;
	REP(i,1000001)perm[i]=perm[i-1]*i%mod;
	inv[1000000]=mod_pow(perm[1000000],mod-2);
	for(int i=999999;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}


signed main(){
	int R,G,B,N;
	cin>>R>>G>>B>>N;
	int ans=0;
	rep(i,3001)rep(j,3001){
		int k=N-i*R-j*G;
		if(k>=0&&k%B==0)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static final int MAX = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashMap<Integer, Integer>[] d = new HashMap[n+1];
        for (int i = 0; i <= n; i++) {
            d[i] = new HashMap<Integer, Integer>();
        }

        for (int i = 0; i < m; i++) {
            int xLi = sc.nextInt();
            int xRi = sc.nextInt();
            int xDi = sc.nextInt();
            d[xLi].put(xRi, xDi);
            d[xRi].put(xLi, -xDi);
        }

        Queue<Integer> q = new LinkedList<Integer>();
        int[] pos = new int[n+1];
        Arrays.fill(pos, MAX);

        for (int i = 1; i <= n; i++) {
            if (pos[i] != MAX) continue;

            q.add(i);
            pos[i] = 0;
            while (!q.isEmpty()) {
                int f = q.poll();

                for (Integer k : d[f].keySet()) {
                    Integer vFK = d[f].get(k);

                    if (pos[k] != MAX) {
                        if (pos[k] != pos[f] + vFK) {
                            System.out.println("No");
                            return;
                        }
                    } else {
                        q.add(k);
                        pos[k] = pos[f] + vFK;
                    }
                }
            }
        }
        System.out.println("Yes");
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    int dis_a = x;
    int dis_b = k - x;
    res += min(dis_a, dis_b);
  }
  cout << 2 * res << "\n";
  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline
    #define re register
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
#define N 100005
char s[N];
int main(){
	scanf("%s",s);
	if(s[0]=='C') puts("Rainy");
	else if(s[0]=='S') puts("Cloudy");
		else puts("Sunny");
	return 0;
}

Measured memory_bytes: 128
mod=1000000007

k=int(input())

if k==1:
    print(1)
    exit()
elif k==2:
    print(2)
    exit()
    
counter = 0
primes = [2, 3]

for n in range(5, k+1, 2):
    isprime = True
    for i in range(0, len(primes)):
        counter+=1
        if primes[i]**2 > n:
            break
        counter += 1
        if n % primes[i] == 0:
            isprime = False
            break
    if isprime:
        primes.append(n)    

#print(primes)
num=[0]*(k+1)

for i in range(1,k+1):
    for a in primes:
        b=i
        while b>1:
            if b%a==0:
                num[a]+=1
                b=b//a
            else:
                break

ans=1
        
for a in primes:
    if num[a]>0:
        ans=ans*(num[a]+1)%mod
        
#print(num)
print(ans)

Measured memory_bytes: 3064
# https://atcoder.jp/contests/agc019/tasks/agc019_a

q, h, s, d = map(int, input().split())
n = int(input())
ans = (n // 2) * min([q * 8, h * 4, s * 2, d]) + (n % 2) * min([q * 4, h * 2, s])
print(ans)

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli x , num1 , num2 ;
    cin >> x >> num1 >> num2 ;
    cout << (abs(x - num1) < abs(x - num2) ? 'A' : 'B' ) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,ans=0;
    std::cin >> n>>k;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        ans+=min(x,abs(x-k));
    }
    std::cout << ans*2 << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
typedef vector<pii> vp;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;
 
int main() {
	string s, str = "CODEFESTIVAL2016";
	cin >> s;
	
	int ans = 0;
	REP(i, s.size()) if (s[i] != str[i]) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

bool isPair(vector<ll> a,vector<ll> b){
    ll d=0;
    for(ll i=0;i<a.size();i++){
        d+=(a[i]-b[i])*(a[i]-b[i]);
    }
    ll d1=sqrt(d);
    if(d1*d1==d){
        return true;
    }
    return false;
}

int main() {

    IO; 

    ll n;
    cin>>n;
    ll d;
    cin>>d;
    vector<vector<ll>> b(n);
    for(ll i=0;i<n;i++){
        vector<ll> c;
        for(ll j=0;j<d;j++){
            ll x;
            cin>>x;
            c.push_back(x);
        }
        b[i]=c;
    }

    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ans+=(isPair(b[i],b[j]));
        }
    }
    cout<<ans<<endl;
}

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

typedef pair<int, int> ii;

const int N = 104;
int n, topo[N];
vector<ii> ans;

void sol() {
	int numTopo = 0;
	if (n % 2 == 0) {
		for (int i = 1; i <= n/2; ++i) topo[i] = topo[n-i+1] = ++numTopo;
	}
	else {
		--n; 
		for (int i = 1; i <= n/2; ++i) topo[i] = topo[n-i+1] = ++numTopo;
		topo[++n] = ++numTopo; 
	}

	for (int i = 1; i <= n; ++i) for (int j = i+1; j <= n; ++j) {
		if (topo[i] == topo[j]) continue;
		ans.push_back(ii(i, j));
	}

	cout << ans.size() << '\n';
	for (ii edge : ans) cout << edge.first << " " << edge.second << '\n';
}

int main() {
	if (fopen("input.txt", "r")) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}

	cin >> n;

	sol();

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

lli n ,w;
vector<pair<lli, lli > >vec;

lli pd[100010];

void read(){
  cin >> n >> w;
  for(int i=0;i<n;i++){
    lli a, b;
    cin >> a >> b;
    vec.push_back({a, b});
  }
}

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

  for(int i=0;i<=1e5;i++) pd[i] = 1e15;

  read();
  pd[0] = 0;
  lli ans = 0;
  for(lli i=0;i<n;i++){
    for(lli j=1e5;j>=vec[i].S;j--){ //Se fizer começando de vec[i].S e indo até 1e5 ele pode repetir os itens
      pd[j] = min(pd[j], pd[j-vec[i].S] + vec[i].F);
      if(pd[j] <= w){
        ans = max(ans, j);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r,d,x,i,ans,y;
    cin>>r>>d>>x;
    y=x;
    for(i=1;i<=10;i++){
        ans=r*x-d;
        cout<<ans<<endl;
        x=ans;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
int main(void){
    ll n,k;cin>>n>>k;
    ll res=0;
    for(ll i=k;i<=n+1;i++){
        ll l=i*(i-1)/2,r=(2*n+1-i)*i/2;
        ll buf=r-l+1;
        res+=buf;
        res%=mod;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3580
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
res = 0
a = [str(i) for i in range(10)]
for num in itertools.product(a, repeat=3):
    p = 0
    for i,j in enumerate(s):
        if j == num[p]:
            p += 1
            if p == 3:
                res += 1
                break
print(res)

Measured memory_bytes: 67032
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main(){
    queue<int> qcost;
    queue<string> qstr;
    int time = 0;
    int num, qtime, tmpInt;
    string tmpStr;
    cin >> num >> qtime;
    int i;
    for(i = 0; i < num; i++){
        cin >> tmpStr >>tmpInt;
        qstr.push(tmpStr);
        qcost.push(tmpInt);
    }
    while(qstr.empty() != true){
        if(qcost.front() - qtime <= 0){
            time = time + qcost.front();
            cout << qstr.front() << " " << time << endl;
            qstr.pop();
            qcost.pop();
        }else{
            time = time + qtime;
            qstr.push(qstr.front());
            qstr.pop();
            qcost.push(qcost.front() - qtime);
            qcost.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 5664
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main() {
    int N, M;
    string S;
    cin >> N;
    map<string, int> yen;
    for(int i=0; i<N; i++){
        cin >> S;
        yen[S] += 1;
    }
    cin >> M;
    for(int i=0; i<M; i++){
        cin >> S;
        yen[S] -= 1;
    }

    int maxx = 0;

    for(auto c : yen){
        maxx = max(c.second, maxx);
    }
    cout << maxx << endl;
}

Measured memory_bytes: 504
///******* In the name of Allah *******///

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

long long int opponent[300013];
void Ok()
{
    long long int a,b,c,d,e,f,g,h,t,s,i,j,k,l1,l2,m,n,r,sum = 0,ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag,swi1,swi2;
    double aa,bb,cc,dd,ee,tot;
    char aaa[1013],bbb[1013],ccc[1013];

    cin>>h>>n;
    for(i=1;i<=n;i++)
    {
        cin>>f;
        sum += f;
    }
    if(sum>=h)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
/* SmartCoder Mar 31, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 100007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int sh[MAXN]; //Stone Height
int dp[MAXN];
int main() {
	fastIO();
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> sh[i];
	}
	dp[1] = 0;
	dp[2] = abs(sh[2] - sh[1]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(abs(sh[i] - sh[i - 1]) + dp[i - 1],
				abs(sh[i] - sh[i - 2]) + dp[i - 2]);
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    long long int a;
    int b;
    scanf("%lld%d", &a, &b);
    long long int avr, total;
    total = a + b;
    avr = total/2;

    if(total%2 == 1) {
        printf("%lld\n", avr + 1);
    }
    else {
        printf("%lld\n", avr);
    }

    return 0;
}

Measured memory_bytes: 128
n = int(input())
j = [0,0,0,0]
for i in range(0,n):
    s = input()
    if s == "AC":
        j[0] += 1
    elif s == "WA":
        j[1] += 1
    elif s == "TLE":
        j[2] += 1
    elif s == "RE":
        j[3] += 1
print('AC x ' +  str(j[0]))
print('WA x ' +  str(j[1]))
print('TLE x ' +  str(j[2]))
print('RE x ' +  str(j[3]))

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  double a = 0;
  int n;
  cin >> n;
  rep(i,0,n){
    double b;
    cin >> b;
    a += 1/b;
  }
  cout << 1/a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define pn putchar('\n')
#define ps putchar(' ')
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int N=1e5+5;


int main()
{
 ll a,b;
 string s;
 cin>>a>>b;
 if(a>=1&&a<=9&&b>=1&&b<=9)
 cout<<a*b<<endl;
 else
 cout<<-1<<endl;
}





Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

ll N, W;
ll w[101];
ll v[101];
ll bucket[4][101];
ll bucketsz[4];

ll take(ll *b, ll n) {
    ll value = 0;
    for (ll i = 0; i < n; i ++) {
        value += b[i];
    }
    return value;
}

int main() {
    scanf("%lld %lld", &N, &W);
    for (ll i = 0; i < N; i ++) {
        scanf("%lld %lld", &w[i], &v[i]);
    }
    for (ll i = 0; i < N; i ++) {
        ll k = w[i] - w[0];
        bucket[k][bucketsz[k]] = v[i];
        bucketsz[k] ++;        
    }
    //prllf("bucket sz = %d %d %d %d\n", bucketsz[0], bucketsz[1], bucketsz[2], bucketsz[3]);
    for (ll k = 0; k < 4; k ++) {
        sort(bucket[k], bucket[k] + bucketsz[k], std::greater<ll>());
    }
    ll bestvalue = 0;
    for (ll i0 = 0; i0 <= bucketsz[0]; i0 ++)
    for (ll i1 = 0; i1 <= bucketsz[1]; i1 ++)
    for (ll i2 = 0; i2 <= bucketsz[2]; i2 ++)
    for (ll i3 = 0; i3 <= bucketsz[3]; i3 ++) {
        ll weight = 0, value = 0;
        value += take(bucket[0], i0);
        value += take(bucket[1], i1);
        value += take(bucket[2], i2);
        value += take(bucket[3], i3);
        weight = (w[0] + 0) * i0 + (w[0] + 1) * i1 + (w[0] + 2) * i2 + (w[0] + 3) * i3;
        //prllf("weight = %d value = %d\n", weight, value);
        if (weight <= W && bestvalue < value) {
            bestvalue = value;
        }
    }
    printf("%lld\n", bestvalue);
}

Measured memory_bytes: 128
import java.util.*

import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val guide = IntArray(n+1) { Int.MAX_VALUE }
    val visited = BooleanArray(n+1) { false }
    guide[0] = 0
    visited[0] = true
    guide[1] = 0
    visited[1] = true
    val ab = Array(n+1){ mutableSetOf<Int>() }
    repeat(m) {
        val route = readLine()!!.split(' ').map { it.toInt() }
        ab[route[0]].add(route[1])
        ab[route[1]].add(route[0])
    }

    val q = ArrayDeque<Int>()
    q.add(1)
    fun check() {
        while(q.isNotEmpty()) {
            val pos = q.pollFirst()
            ab[pos].forEach {
                if (!visited[it]) {
                    guide[it] = pos
                    q.add(it)
                    visited[it] = true
                }
            }
        }
    }
    check()

    if (visited.firstOrNull { it == false } != null) {
        println("No")
    } else {
        println("Yes")
        for (i in 2..n) {
            println(guide[i])
        }
    }
}


Measured memory_bytes: 111940
#include <bits/stdc++.h>
using namespace std;
 
const long long mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<bool>ok(n+1,true);
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    ok.at(a)=false;
  }
  vector<long long>dp(n+1);
  dp.at(0)=1;
  for(int i=0;i<n;i++){
    for(int next=i+1;next<=min(n,i+2);next++){
      if(ok.at(next)){
        dp.at(next)+=dp.at(i);
        dp.at(next)%=mod;
      }
    }
  }
  cout << dp.at(n) << endl;
}
        
      

Measured memory_bytes: 4044
#include<stdio.h>
#include<algorithm>
#include<map>
#include<string.h>
using namespace std;
int n, m, Res, C[26], Mod = 1000000007;
char p[4010], q[4010];
map<int,int>Map;
struct A{
    int C[26], num;
    bool operator <(const A &p)const{
        for(int i=0;i<26;i++){
            if(C[i]!=p.C[i])return C[i]<p.C[i];
        }
        return num<p.num;
    }
}w[4010];
void Do(char *a, char *b){
    int i, j;
    for(i=0;i<26;i++)w[0].C[i] = C[i]=0;
    Map.clear();
    Map[0]=1;
    for(i=0;a[i]&&b[i];i++){
        C[a[i]-'a']++, C[b[i]-'a']--;
        for(j=0;j<26;j++)w[i+1].C[j]=C[j];
        long long s = 0;
    }
    int K = i+1, bb = 0;
    for(i=0;i<K;i++)w[i].num=i;
    sort(w,w+K);
    for(i=1;i<K;i++){
        for(j=0;j<26;j++)if(w[i].C[j]!=w[bb].C[j])break;
        if(j!=26)bb=i;
        else{
            Res = max(Res, w[i].num-w[bb].num);
        }
    }
}
int main(){
    int i, j;
    scanf("%s%s",p,q);
    n = strlen(p), m = strlen(q);
    for(i=0;i<n;i++) Do(p+i,q);
    for(i=0;i<m;i++) Do(p,q+i);
    printf("%d\n",Res);
}

Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define MEMBER_NUM 10

int max_3_score(std::vector<int> scores) {
  std::sort( scores.begin(), scores.end() );
  int score = 0;
  for (int i = 0; i < 3; i++) {
    score += scores[MEMBER_NUM - i - 1];
  }
  return score;
}

int main() {

  std::vector<int> w_scores;
  std::vector<int> k_scores;

  std::string score;
  int count = 0;
  while ( count != 20 ) {
    std::cin >> score;
    if ( count < 10 ) {
      w_scores.push_back( std::stoi(score) );
    } else if ( count < 20 ) {
      k_scores.push_back( std::stoi(score) );
    }
    count++;
  }

  std::cout << max_3_score( w_scores ) << " " << max_3_score( k_scores ) << std::endl;
  
}

Measured memory_bytes: 3132
import sys
input = sys.stdin.readline
N, T = map(int, input().split())
a = []
for _ in range(N):
  w, v = map(int, input().split())
  a.append((w, v))
a.sort()
dp = [[0] * (T + 1) for _ in range(N + 1)]
for i in range(N):
  w, v = a[i]
  for j in range(T):
    if j + w >= T:
      dp[i + 1][T] = max(dp[i + 1][T], dp[i][j] + v)
    else:
      dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v)
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
  dp[i + 1][T] = max(dp[i + 1][T], dp[i][T])
print(max(dp[-1]))

Measured memory_bytes: 114780
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

// 2 1 3 4 7 11 18
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n+5];
    a[0] = 2;
    a[1] = 1;
    rep(i,2,n+1){
      a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#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>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  const int MOD = 1e9 + 7;
  int N, M;
  cin >> N >> M;

  vector<int> a(M);
  REP(i, M) cin >> a[i];
  if (M == 0) a.push_back(N + 2);

  vector<int> dp(N + 1, 0);

  auto iter = a.begin();
  REP(i, N + 1){
    if (*iter == i) {
      iter++;
      continue;
    }
    if (i == 0) dp[i] = 1;
    else if (i == 1) dp[i] = dp[i - 1];
    else dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
  }

  cout << dp[N] << endl;
  return 0;
}


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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextInt();
		int w = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans;
		if(n != 1) {
			ans = Math.max(Math.abs(w-a[n-1]), Math.abs(a[n-2]-a[n-1]));
		}else {
			ans = Math.abs(w-a[0]);
		}
		System.out.println(ans);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 25904
#include <stdio.h>
int main(void)
{
	int i,r,h[31]={0};
	for(i=1;i<=28;i++){
		scanf("%d",&r);
		h[r]=1;
	}
	for(i=1;i<=30;i++){
		if(h[i]==0){
			printf("%d\n",i);
		}
	}
	return 0;
}


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

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

	int cnt = 0;
	for (int i = 0; i < s.length()-1; i++) {
		if (s.at(i) == s.at(i+1)) {
			cnt++;
		}
	}
	int ans = s.length() - cnt;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n;
	char card[101],field;
	int i,j,par[10];
	int tmp;
	
	while (scanf("%d", &n) * n != 0){
		field = 0;
		for (i = 0; i < 10; i++){
			par[i] = 0;
		}
		scanf("%s", card);
		
		for (i = 0; card[i] != 0; i++){
			switch (card[i]){
				case 'M':
				  par[i % n]++;
				  break;
				case 'S':
				  field += par[i % n] + 1;
				  par[i % n] = 0;
				  break;
				case 'L':
				  par[i % n] += field + 1;
				  field = 0;
				  break;
			}
		}
		
		for (i = 0; i < n-1; i++){
			for (j = 0; j < n-1; j++){
				if (par[j] > par[j+1]){
					tmp = par[j];
					par[j] = par[j+1];
					par[j+1] = tmp;
				}
			}
		}
		for (i = 0; i < n; i++){
			printf("%d ", par[i]);
		}
		printf("%d\n", field);
	}
	
	return (0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    int n, k;
    cin>>n>>k;
    if(n<10)cout<<k+(100*(10-n));
    else cout<<k;   
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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

int main(){
   int a,b,c;
   for(int i =0;i<4;i++){
      cin >> a>>b;
       if (a == 1) {
       c = 6000*b;
       cout << c<<endl;
       } else if (a == 2) {
       c = 4000*b;
       cout <<c<<endl;
       } else if (a ==3) {
       c = 3000*b;
       cout <<c<<endl; 
       } else if (a ==4) {
       c = 2000*b;
       cout <<c<<endl; 
       }
   }
}


Measured memory_bytes: 3052
#include <stdio.h>
 int main(void){    
 int N,M,i,j,A[1000],Ai,Bj,count[1000],max_count=0,max_game=-1;  
   scanf("%d%d",&N,&M);  
     for(i=0;i<N;i++){  
       scanf("%d",&A[i]);          
   count[i]=0;   
  }    
 for(j=0;j<M;j++){   
      scanf("%d",&Bj);   
      for(i=0;i<N;i++){     
        if(A[i]<=Bj){count[i]++;break;}   
      }     
}    
   for(i=0;i<N;i++){        
 if(max_count<count[i]){    
         max_count=count[i];     
        max_game=i;      
   }    
 }      
 printf("%d\n",max_game+1);
return 0;
 } 

Measured memory_bytes: 604
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
#MOD = 1000000007
MOD = 10000
EPS = 0.000000001
sys.setrecursionlimit(100000)


while True:

    N = int(input())
    if N == 0:
        break

    table = [int(input()) for _ in range(N)]
    table.sort() #待ち時間が短い人を先に処理する

    ans = 0
    current = 0

    for i in range(N):
        ans += current
        current += table[i]

    print("%d"%(ans))


Measured memory_bytes: 14016
def get_coord(C):
    for xi in range(0, 101):
        for yi in range(0, 101):
            H = 10 ** 9 + 1
            success = True
            for i in range(0, len(C)):
                d = abs(xi - C[i][0]) + abs(yi - C[i][1])
                if i == 0:
                    th = H - d
                    H -= th - C[i][2]
                else:
                    nh = H - d
                    if nh >= 0:
                        if C[i][2] == nh:
                            continue
                        else:
                            success = False
                            break
                    else:
                        if C[i][2] == 0:
                            continue
                        else:
                            success = False
                            break

            if success:
                return (xi, yi)
    return (-1, -1)


def solve(C):
    C.sort(key=lambda x: x[2], reverse=True)
    x, y = get_coord(C)
    for c in C:
        if c[2] != 0:
            h = abs(x - c[0]) + abs(y - c[1]) + c[2]
            return [str(x), str(y), str(h)]


if __name__ == "__main__":
    N = int(input())
    C = []
    for n in range(N):
        d = input().split(" ")
        C.append((int(d[0]), int(d[1]), int(d[2])))
    print(" ".join(solve(C)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
#define eps 1e-15
#define f first
#define s second
typedef long long ll;
int main()
{
    fastIO
    int n;
    cin>>n;

    vector<ll>v;
    vector<ll>w;
    ll x,y;
    for (int i=0; i<n; ++i)
    {
        cin>>x>>y;
        v.push_back(x+y);
        w.push_back((x-y));
    }
    sort(v.begin(),v.end());
    sort(w.begin(),w.end());

    cout<<max(v[n-1]-v[0],w[n-1]-w[0]);


}


Measured memory_bytes: 6652
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, readline().split())
K = [list(map(int1, readline().split())) for _ in range(M)]
P = list(map(int, readline().split()))

ans = 0
for bit in range(1 << N):
    for i in range(M):
        flag = True
        acc = 0
        for s in K[i][1:]:
            if (bit & (1 << s)):
                acc += 1
        if acc % 2 != P[i]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int N, M;
int field[10000], dice;

int main() {
	while(scanf("%d %d", &N, &M), N || M) {
		int now = 0;
		rep(i, N) scanf("%d", &field[i]);
		int ans;
		bool flag = false;
		rep(i, M) {
			scanf("%d", &dice);
			now = now + dice;
			now = now + field[now];
			if(now < 0) now = 0;
			if(!flag) {
				if(now >= N) flag = true;
				ans = i;
			}
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 2e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

int a[N],dp[N];

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[1] = 0;
	for(int i=2;i<=n;i++){
		dp[i] = 2e9;
		for(int j=1;j<=k;j++){
			if(i - j == 0)break;
			dp[i] = min(dp[i],dp[i-j] + abs(a[i-j] - a[i]));
		}
	}
	
	cout << dp[n] << endl;
}

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

n = int(input())
llist = list(map(int, input().split()))
llist.sort()
ans = 0

for i in range(n-2):
  for j in range(i+1,n-1):
    if llist[i] != llist[j]:
      for k in range(j+1,n):
        if llist[j] != llist[k]:
          if llist[i] + llist[j] > llist[k]:
            ans += 1

print(ans)

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  cout << n * n * n << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

char s[100010];
int k;

int main(){

  scanf( "%s" , s );
  scanf( "%d" , &k );
  int n = strlen( s );

  REP( i , n ){
    if( s[i] != 'a' && 'z' - s[i] + 1 <= k ){
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }

  s[n-1] = ( s[n-1] - 'a' + k ) % 26 + 'a';

  printf( "%s\n" , s );

  return 0;
}


Measured memory_bytes: 384