akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <cstdio>
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;

double dot(point a,point b){
  return a.x*b.x+a.y*b.y;
}

point projection(point a,point b,point c){
  point base = b - a;
  double r = dot(c-a,base)/(abs(base)*abs(base));
  return a+base*r;
}

int main(){
  point a,b,c;
  cin >>a.x>>a.y>>b.x>>b.y;
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> c.x >> c.y;
    point res = projection(a,b,c);
    printf("%.10f %.10f\n",res.x,res.y);
  }
  return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e4+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=998244353;
void io(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll a[maxn],dp[maxn],f[maxn];
int main()
{
	io();
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i]; 
	ll ans=0; 
	for(int i=1;i<=n;i++)
	{
		dp[0]+=1;
		for(int j=k;j>=a[i];j--)
			dp[j]=(dp[j]+dp[j-a[i]])%mod;
		ans=(ans+dp[k])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

ll N, A, B;
vector<ll> h;

bool C(ll mid) {
    ll t = 0;
    for (int i = 0; i < N; i++) {
        if (h[i] > B * mid) {
            t += (h[i] - B * mid + (A - B - 1)) / (A - B);
        }
    }
    return t <= mid;
}

int main() {
    cin >> N >> A >> B;
    h.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }
    ll ok = 1e9;
    ll ng = 0;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        if (C(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}


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

int main(){
  int t_cook[5];
  int t_wait[5];
  int longest = 0;
  int ans = 0;

  for(int i=0; i<5; i++){
    cin >> t_cook[i];
    t_wait[i] = 10 - t_cook[i]%10;
    if(t_wait[i]==10) t_wait[i]=0;

    if(t_wait[longest] < t_wait[i]){
        longest = i;
    }
    ans += t_cook[i]+t_wait[i];
  }

  ans -= t_wait[longest];
  printf("%d\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	/* 入力 */
	int w = scan.nextInt();
	int a = scan.nextInt();
	int b = scan.nextInt();

	/* 赤が左 */
	if(a < b){
	    if(a+w < b){
		System.out.println(b-(a+w));
	    }else{
		System.out.println(0);
	    }
	}
	/* 赤が右 */
	else if(b < a){
	    if(b+w < a){
		System.out.println(a-(b+w));
	    }else{
		System.out.println(0);
	    }
	}
	/* 始点が重なる */
	else{
	    System.out.println(0);
	}
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll t = 7, s = 0;
    for (int i = 1; i < k * 10; i++) {
        s += t;
        s %= k;
        t *= 10;
        t %= k;
        if (s == 0) {
            cout << i << endl;
            exit(0);
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	long int a[n];
	long int sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);

	cout << a[0] << " " << a[n-1] << " " << sum << endl;
}



Measured memory_bytes: 3220
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			long x = sc.scanLong();
			long[] arr = new long[n];
			for (int i = 0; i < n; ++i)
				arr[i] = sc.scanLong();
			long runner = arr[0];
			long res = 0;
			for (int i = 1; i < n; ++i) {
				runner += arr[i];
				long ops = 0;
				if (runner > x) {
					ops += runner - x;
				}
				res += ops;
				runner = Math.max(0, arr[i] - ops);
			}
			System.out.println(res);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 33480
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define ms(x,v)    memset(x, v, sizeof x)
#define endl '\n'
#define cnl cout<<endl;
#define fr(i,b) for(ll i=0; i<b;i++)
#define frr(i,a,b) for(ll i=a;i<=b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
ll i,j;
int main(){
 ll a,b; cin>>a>>b;
  if(b==1){
    cout<<0<<endl;
    return 0;
  }
 ll temp=a;
 ll cnt=1;
 while((temp)<b){
  temp--;
  temp=temp+a;
  cnt++;
 }
cout<<cnt<<endl;
  
return 0;
}
 

Measured memory_bytes: 256
import javax.management.Query;
import javax.print.attribute.SupportedValuesAttribute;
import java.io.*;
import java.lang.reflect.Array;
import java.security.interfaces.DSAKeyPairGenerator;
import java.util.*;
import java.util.function.Predicate;


public class Main {

    static class TaskB {

        public void solve(InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();
            long d = in.nextLong();

            long minMoves = Math.abs(n)/d;
            if(minMoves>k)
            {
                out.print(Math.abs(n) - (k*d));
                return;
            }
            if(n<0)
            {
                n+=minMoves*d;
            }
            if(n>0)
            {
                n-=minMoves*d;
            }
            k-=minMoves;
            if(k%2==0)
            {
                out.print(Math.abs(n));
                return;
            }
            out.print(Math.abs(Math.abs(n)-d));

        }
    }


    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }



    static void sort(int[] a)
    {
        ArrayList<Integer> list = new ArrayList<>();
        for(int i: a)list.add(i);
        Collections.sort(list);
        for(int i = 0; i < a.length; i++)a[i]=list.get(i);
    }


    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public InputReader(InputStream inputStream) {
            this.reader = new BufferedReader(
                    new InputStreamReader(inputStream));
        }

        public String next() {
            while (!tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
    }
}

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

using namespace std;

int main(int argc, char* argv[]) {
  long long x;
  cin >> x;

  if (x <= 6) {
    cout << 1 << endl;
    return 0;
  }

  long long ret = floor(((long double)x / 11)) * 2;
  long long rest = x - ret * 11 / 2;
  if (rest > 0 && rest <= 6)
    ++ret;
  else if (rest > 6)
    ret += 2;
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma optimize("unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1e18)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)



void solve()
{
   ld d,t,s;
   cin>>d>>t>>s;
   if(t>=(ld)d/(ld)s)
   {
	   cout<<"Yes\n";
   }
   else
   {
	   cout<<"No\n";
   }
   
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 3752
/**
 *    author:  morato
 *    created: 25.08.2020 20:09:06
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> freq;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    freq[s]++;
  }
  int mx = 0;
  for (auto it = freq.begin(); it != freq.end(); it++) {
    mx = max(mx, it->second);
  }
  vector<string> v;
  for (auto it = freq.begin(); it != freq.end(); it++) {
    if (it->second == mx) {
      v.push_back(it->first);
    }
  }
  sort(v.begin(), v.end());
  for (auto x : v) {
    cout << x << '\n';
  }
  return 0;
}

Measured memory_bytes: 27228
// B - Can you solve this?
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)

int main(){
	int N,M,C;cin>>N>>M>>C;
	vi B(M); rp(i,M) cin>>B[i];

	int count = 0;
	rp(i,N){
		int s = C;
		rp(j,M){
			int a; cin>>a;
			s += a*B[j];
		}
		if(s>0) ++count;
	}
	cout<< count <<endl;
}

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

int main() {
  int n, k; cin >>n >>k;
  vector<int> l(n);
  for (int i=0; i<n; i++) cin >>l.at(i);
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  int ans = 0;
  for (int i=0; i<k; i++){
    ans += l.at(i);
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 256
import math
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

lcm = lcm(C,D)

u_b_ans = (B//C + B//D) - B//lcm
u_a_ans = ((A-1)//C + (A-1)//D) - (A-1)//lcm

print(B-A+1 - u_b_ans + u_a_ans)


Measured memory_bytes: 61964
from heapq import heapify, heappop, heappush
q = []
heapify(q)
b = True
while b:
    li = input().split()
    if li[0] == 'insert':
        li[1] = int(li[1])
        heappush(q, li[1]*(-1))
    elif li[0] == 'extract':
        print(heappop(q)*-1)
    else:
        b = False


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

int main()
{
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
        if (S-X-Y >= 0 && S-X-Y <= K) {
          count++;
        }
    }
  }
  cout << count << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 (b<a) { a=b; return 1; } return 0; }



int x,n, a[101];
bool b[101] = {};
void solve(){
	cin >> x >> n;
	int ans = 101;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		b[a[i]] = 1;
	}
	for(int i = 100; i >= 0; i--){
		if(b[i]) continue;
		if(abs(ans-x) >= abs(i-x)){
			ans = i;
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3688
def LI(): return list(map(int,input().split()))
N,M = LI()
ks = [LI() for _ in range(M)]
p = LI()
ans = 0
for i in range(2**N):
    bit = [i>>j & 1 for j in range(N)]
    for j,x in enumerate(ks):
        if p[j]!=sum([bit[y-1] for y in x[1:]])%2:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<stack>
#include<set>
#include<queue>
#include<algorithm>

using namespace std;

int l,r;

int a[100][100];

int main()
{
    cin>>l>>r;
    for(int i = 1;i<=l;i++)
    {
        for(int  j = 1;j<=r;j++)
        {
            char temp;
            cin>>temp;
            if(temp=='#')
            {
                a[i][j] = -1000000;
                a[i-1][j]++;a[i][j-1]++;a[i][j+1]++;
                a[i+1][j]++;a[i-1][j-1]++;a[i-1][j+1]++;
                a[i+1][j-1]++;a[i+1][j+1]++;
            }
        }
    }

    for(int i =1;i<=l;i++)
    {
        for(int j =1;j<=r;j++)
        {
            if(a[i][j]>=0)
            cout<<a[i][j];
            else
                cout<<'#';

        }
        cout<<endl;
    }

	return 0;
}


Measured memory_bytes: 256
def unjfen(s)
    s.split(?/).map {|row| row.each_char.map {|c| c == ?b ? ?b : [?.] * c.to_i}.flatten}
end

def jfen(rows)
    rows.map {|row| row.join.gsub(/\.+/){|e| e.size}} * ?/
end

loop do
    a = unjfen(gets.chomp)
    break if $_ =~ /#/
    i1, j1, i2, j2 = gets.split.map(&:to_i)
    a[i1-1][j1-1] = ?.
    a[i2-1][j2-1] = ?b
    puts jfen(a)
end

Measured memory_bytes: 8880
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    int h, n;
    std::cin >> h >> n;
    std::vector<int> a(n);
    string ans = "No";
    rep(i, n) std::cin >> a.at(i);
    rep(i, n){
        h = h - a.at(i);
        if(h <= 0){
            ans = "Yes";
            break;
        }
    }
    std::cout << ans << std::endl;
}


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

int main() {
  int N, ans = 0, l, n;
  cin >> N;
  for(int i = 0; i < N;i++) {
    cin >> l >> n;
    for(int u = 0;u <= n - l;u++) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int dx[] = {-1, 0};
int dy[] = {0, -1};

int main() {

    string S, T;
    cin >> S >> T;

    vector<vector<int>> dp(S.size() + 1, vector<int>(T.size() + 1, 0));

    for (int i = 0; i < S.size(); i++) {
        for (int j = 0; j < T.size(); j++) {
            if (S[i] == T[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            if (S[i] != T[j]) {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

//    for (int i = 0; i < S.size() + 1; i++) SHOW_VECTOR(dp[i]);

    string ans = "";
    int y = S.size();
    int x = T.size();
    int d = dp[y][x];
    while (d != 0) {
        bool b = false;
        for (int i = 0; i < 2; i++) {
            int toY = dy[i] + y;
            int toX = dx[i] + x;
            if (d == dp[toY][toX]) {
                y = toY;
                x = toX;
                b = true;
                break;
            }
        }
        if (b) continue;
        y--, x--;
        d = dp[y][x];
        ans += S[y];
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}
















































Measured memory_bytes: 35584
import sys
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(100):
    if (x - i in p):
        pass
    else:
        print(x - i)
        sys.exit()

    if (x + i in p):
        pass
    else:
        print(x + i)
        sys.exit()

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

int main(){
  int n, ans;
  cin >> n;
  
  for(int i = 1; i <= n; i++){
    if(i < 10) ans++;
    else if(i >= 100 && i < 1000) ans++;
    else if(i >= 10000 && i < 100000) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
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 = new List<int>();

            var maxVal = 0;
            for(var i = 0; i < n; i++){
                var t = int.Parse(Console.ReadLine());
                a.Add(t);
                maxVal = Math.Max(maxVal, t);
            }
            var secondMax = a.OrderByDescending(i => i).ElementAt(1);

            foreach(var x in a){
                if(x == maxVal){
                    Console.WriteLine(secondMax);
                }else{
                    Console.WriteLine(maxVal);
                }
            }
        }
    }
}


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

int main() {
  // ここにプログラムを追記
  int ans;
  string s;
  cin >> s;
  if(s[0] == '1') ans++;
  if(s[1] == '1') ans++;
  if(s[2] == '1') ans++;
  cout << ans;
}


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

using namespace std;

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

	int sizeS = argS.size();
	string ret = "";
	for (uint i = 0; i < sizeS; ++i) {
		if (i % 2 == 0) {
			ret.push_back(argS.at(i));
		}
	}
	
	cout << ret << endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


int a,b;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>a>>b;

    int n = 1000;
    vl t(n);
    t[0] = 0;
    REP(i,n){
        t[i+1] += t[i]+i+1;
    }

    ll diff = b-a;
    ll ans = 0;
    FOR(i,1,n){
        auto pos = lower_bound(t.begin()+i+1, t.end(), t[i]+diff);
        if((*pos) == t[i]+diff){
            ans = t[i]-a;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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 const INF = 1001001001;
ll const MOD = 1000000007;


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

string s;
cin >> s;

ostringstream oss;

oss << (s.size()-2) << flush;
string t = oss.str();

cout << s[0] << t << s[s.size()-1] << endl;

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string s, ring, copy;
  int n;
  int cnt = 0;

  cin >> s;
  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    cin >> ring;
    copy = ring;
    copy += ring;
    if (copy.find(s) != -1){
      cnt++;
    }
  }
  printf("%d\n", cnt);

  return (0);
}

Measured memory_bytes: 1240
'use strict'

const main = input => {
	const args = input.split('\n')[0].split(' ')
	const a = parseInt(args[0], 10)
	const b = parseInt(args[1], 10)
	if (a >= 13) console.log(b)
	else if (a >= 6) console.log(b / 2)
	else console.log(0)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <ios>
#include <sstream>
using namespace std;

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}

int vv(int x, unsigned int y){
    ostringstream str_x;
    str_x << x;
    size_t len = str_x.str().length();
    for (int i = 0; i < (y - len > 0 ? y - len : 0); ++i) {
        cout << 0;
    }
    cout << x << endl;
    return 0;
}

int main(){
    int s, i = 0;
    cin >> s;
    vector < int > li(1000000, 0);
    li.at(0) = s;
    while (true){
        if (s == 1) {
            cout << 4 << endl;
            break;
        }
        if (s == 2) {
            cout << 4 << endl;
            break;
        }
        if (s == 4) {
            cout << 4 << endl;
            break;
        }

        if (li[i] % 2 == 0) li[i+1] = li[i]/2;
        else li[i+1] = 3 * li[i] + 1;
        if (li[i+1] == 4) {
            cout << i + 5 << endl;
            break;
        }
        i++;
    }


    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main(){
	int n,m=0,flag=0;
	scanf("%d",&n);
	for(int i=0;i<101;i=i+4){
		m=i;
		for(int j=0;j<101;j=j+7){
			m=m+j;
			if(m==n){
				flag=1;
				break;
			}
		}
		if(flag==1){
			break;
		}
	}
	if(flag==0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define _h cout<<"here"<<endl;
#define pr(a) cout<<a<<endl;
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define fi first
#define se second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
const int MAXN = 3e5+10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int e=0;
	int w = 0;
	cin>>n;
	char c;
	int a[MAXN];
	rep(n)
	{
		cin>>c;
		if(c=='E')
		{
			a[i] = 1;
			e++;
		}
		else
		{
			a[i]=0;
			w++;
		}
	}    
	int w1=0;
	int e1 = 0;
	int ans = inf;
	rep(n)
	{

		if(a[i])
		{
			e1++;
			ans = min({ans,w1+e-e1});
		}
		else
		{
			ans = min({ans,w1+e-e1});
			w1++;
			// ans = min({ans,e1+w-w1});
		}
	}
	cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 1408
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n,max_num = -1000001,min_num = 1000001,tmp;
    long long int sum = 0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&tmp);
        sum += tmp;
        max_num = max(max_num,tmp);
        min_num = min(min_num,tmp);
    }
    printf("%d %d %lld\n",min_num,max_num,sum);
}


Measured memory_bytes: 2736
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        char[] s = sc.next().toCharArray();
        char prev = s[0];
        int ans = 0;
        for(int i = 1; i < s.length; i++){
            if(prev != s[i]) ans++;
            prev = s[i];
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int price;
	int i;
	
	while (scanf("%d", &price), price != 0){
		for (i = 0; i < 9; i++){
			int money;
			
			scanf("%d", &money);
			price -= money;
		}
		printf("%d\n", price);
	}
	
	return 0;
}

Measured memory_bytes: 600
program name
    implicit none
    integer(4):: n,m
    integer(4):: s,c
    integer(4),allocatable:: keta(:)
    integer(4):: i,ans

    read*, n,m
    allocate(keta(n))
    
    keta(:) = -1
    do i=1,m
        read*, s,c
        
        if (keta(s) /= -1 .and. keta(s) /= c) call die
        keta(s) = c
    end do

    if (keta(1) == 0 .and. n > 1) call die
    if (keta(1) == -1 .and. n > 1) keta(1) = 1

    do i=1,n
        if (keta(i) == -1) keta(i) = 0
    end do

    ans=0
    do i=1,n
        ans=ans+keta(i)*10**(n-i)
    end do

    print*, ans

contains
subroutine die
    print*, -1
    stop
end subroutine

end program name

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.InputMismatchException;
class Main{
public static void main(String args[]){

    Scanner scan = new Scanner(System.in);
    try{
int W = scan.nextInt();
int H = scan.nextInt();
int x = scan.nextInt();
int y = scan.nextInt();
int r = scan.nextInt();


int temp;


if(0<=x-r && 0<=y-r && x+r <= W && y+r<=H){
	System.out.println("Yes");
}
else 	System.out.println("No");




}catch (InputMismatchException e) {
        	System.out.println("try again!!");
        }





}
}



Measured memory_bytes: 26364
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int[2]> A(N);
  for(int i=0;i<N;i++)cin>>A[i][0]>>A[i][1];
  for(int i=0;i+2<N;i++){
    for(int j=0;j<3;j++)
      if(A[i+j][0]!=A[i+j][1])goto home;
    puts("Yes");
    return 0;
    home:;
  }
  puts("No");
}

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

namespace Atcoder_0404
{
    class Program
    {

        static void Main(string[] args)
        {
            var NM = GetInput_int();
            int _dayLangth = NM[0];
            int _homeWorkCount = NM[1];
            var _workWeights = GetInput_int();
            int allDays = 0;
            foreach (var data in _workWeights)
            {
                allDays += data;
            }
            int result = _dayLangth - allDays;
            if (result < 0)
            {
                result = -1;
            }
            Console.WriteLine(result); ;
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
    }
}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  int a = A+B, b = A-B, c =  A*B;
  
  vector<int> vec = {a,b,c};
  sort(vec.begin(),vec.end());
  cout << vec.at(2) << endl;
}


Measured memory_bytes: 256
n=gets.to_i
arr=Array.new
for i in 1..n
   ball=gets.split(" ").map(&:to_i)
   
   left,right=Array.new,Array.new
   left[0],right[0]=ball[0],0
   l,r=0,0
   frag=0
   for j in 0..8
      if ball[j+1]>left[l]
         left[l+1]=ball[j+1]
         l+=1
      elsif ball[j+1]>right[r]
         right[r+1]=ball[j+1]
         r+=1
      else ball[j+1]<left[l] and ball[j+1]<right[r]
         puts "NO"
         frag=1
         break 
      end
   end
   puts "YES" if frag==0
end

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

int main() {
	int N;
	ll C;
	cin >> N >> C;
	vector<ll> x(N), v(N);
	for(int i=0;i<N;i++) {
		cin >> x[i] >> v[i];
	}

	vector<ll> right_score(N), left_score(N);
	ll left = 0, right = 0;
	ll now = 0;
	ll left_ans = 0, right_ans = 0;

	// 左回り
	vector<ll> left_max(N,0);
	for(int i=0;i<N;i++) {
		left += (v[i] - (x[i] - now));
		left_score[i] = left;
		if(i > 0) left_max[i] = max(left_max[i-1], left_score[i]);
		else left_max[i] = left_score[i];
		now = x[i];
		left_ans = max(left_ans, left_score[i]);
	}

	// 右回り
	now = C;
	vector<ll> right_max(N,0);
	for(int i=N-1;i>=0;i--) {
		right += (v[i] - (now - x[i]));
		right_score[i] = right;
		if(i < N-1) right_max[i] = max(right_max[i+1], right_score[i]);
		else right_max[i] = right_score[i];
		now = x[i];
		right_ans = max(right_ans, right_score[i]);
	}

	// 左行ってから右
	ll left_back_ans = 0;
	vector<ll> left_back(N), right_back(N);
	for(int i=0;i<N-1;i++) {
		left_back[i] = (left_score[i] - x[i]);
		// [i+1, N-1]までのrightの最大値
		left_back[i] += right_max[i+1];
		left_back_ans = max(left_back_ans, left_back[i]);
	}
	
	// 右行ってから左
	ll right_back_ans = 0;
	for(int i=N-1;i>=1;i--) {
		right_back[i] = (right_score[i] - (C - x[i]));
		// [0,i-1]までのleftの最大値
		right_back[i] += left_max[i-1];
		right_back_ans = max(right_back_ans, right_back[i]);
	}

	cout << max({left_ans, right_ans, left_back_ans, right_back_ans}) << endl;
}

Measured memory_bytes: 6528
using System;

namespace consoleapp01
{
    class foo
    {
        static void Main()
        {
            int r, D, x;
            string[] st = Console.ReadLine().Split(' ');
            r = int.Parse(st[0]);
            D = int.Parse(st[1]);
            x = int.Parse(st[2]);

            for (int i = 0; i < 10; i++)
            {
                x = r * x - D;
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

//http://kmjp.hatenablog.jp/entry/2019/09/08/0930

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

    int N;
    int S[1<<18];
    cin>>N;

    for(int i=0;i<(1<<N);i++) cin>>S[i];
    sort(S,S+(1<<N));
    multiset<int> T;
    for(int i=0;i<(1<<N)-1;i++){
        T.insert(S[i]);
    }

    vector<int> V;
    V.push_back(S[(1<<N)-1]);
    for(int i=0;i<N;i++){
        vector<int> W=V;
        for(auto v:W){
            auto it=T.lower_bound(v);
            if(it==T.begin()){
                cout<<"No"<<endl;
                return 0;
            }
            it--;
            V.push_back(*it);
            T.erase(it);
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 13568
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int wn = w.size();
  for (int i = 0; i < wn; i++)
    if (w[i] >= 'A' && w[i] <= 'Z') w[i] += 'a' - 'A';
  //cout << w << endl;
  
  int cnt = 0;

  for (;;) {
    string s;
    cin >> s;
    if (s == "END_OF_TEXT") break;

    if (s.size() != wn) continue;

    bool ok = true;
    for (int i = 0; i < wn; i++) {
      char ch = (s[i] >= 'A' && s[i] <= 'Z') ? s[i] - 'A' + 'a' : s[i];
      if (w[i] != ch) {
	ok = false;
	break;
      }
    }

    if (ok) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;

       
  for (int i = a; i < b + 1; i++) {
       int A = i/10000;
   int B = i/1000 - A * 10;
   int C = i/100 - A * 100 - B * 10;
   int D = i/10 - A * 1000 - B * 100 - C * 10;
   int E = i/1 - A * 10000 - B * 1000 - C * 100 - D * 10;
    
    if (A == E && B == D) {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long sum = 0;
		PriorityQueue<Integer> first = new PriorityQueue<Integer>();
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    first.add(a);
		    sum += a;
		}
		int[] mid = new int[n];
		for(int i = 0; i < n; i++){
		    mid[i] = sc.nextInt();
		}
		PriorityQueue<Integer> last = new PriorityQueue<Integer>(Comparator.reverseOrder());
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    last.add(a);
		    sum -= a;
		}
		
		// 計算
		long result = 0;
		long[] largeSum = new long[n+1];
		for(int i = 0; i < n; i++){
		    int min = first.peek();
		    int plus = 0;
		    if(mid[i] > min){
		        plus = mid[i] - min;
		        first.poll();
		        first.add(mid[i]);
		    }
		    largeSum[i+1] = largeSum[i] + plus;
		}
		long[] smallSum = new long[n+1];
		for(int i = 0; i < n; i++){
		    int max = last.peek();
		    int plus = 0;
		    if(mid[n-1-i] < max){
		        plus = max - mid[n-1-i];
		        last.poll();
		        last.add(mid[n-1-i]);
		    }
		    smallSum[n-i-1] = smallSum[n-i] + plus;
		}
		long tmp = 0;
		for(int i = 0; i < n+1; i++){
		    tmp = max(tmp, largeSum[i] + smallSum[i]);
		}
		result = sum + tmp;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 95888
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N, 0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N-1; i++){
        cin >> C[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += B[A[i]];
        if(i == 0)continue;
        if(A[i] - A[i-1] == 1){
            ans += C[A[i-1]];
            //cout << A[i-1] << endl;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
Tbl = %w[2 3 4 5 6 7 8 9 10 11 12 13 1].map(&:to_i)
A, B = gets.split(" ").take(2).map(&:to_i)
puts case Tbl.index(A) <=> Tbl.index(B)
when 1; "Alice"
when -1; "Bob"
else "Draw"
end


Measured memory_bytes: 1788
S = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(S[int(input())-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

#include <iostream>
using i64 = long long;
template<i64 M> struct modint { i64 a;
  constexpr modint(const i64 x = 0): a((x%M+M)%M){}
  constexpr i64 value() const { return a; }
  constexpr modint inv() const { return this->pow(M-2); }
  constexpr modint pow(i64 r) const {
    modint ans(1); modint aa = *this;
    while(r) { if(r & 1) ans *= aa; aa *= aa; r >>= 1; }
    return ans;
  }
  constexpr modint& operator=(const i64 r) { a = (r % M + M) % M; return *this; }
  constexpr modint& operator+=(const modint r) { a += r.a; if(a >= M) a -= M; return *this; }
  constexpr modint& operator-=(const modint r) { a -= r.a; if(a < 0) a += M; return *this; }
  constexpr modint& operator*=(const modint r) { a = a * r.a % M; return *this; }
  constexpr modint& operator/=(const modint r) { (*this) *= r.inv(); return *this; }
  constexpr modint operator+(const modint r) const { return modint(a) += r; }
  constexpr modint operator-(const modint r) const { return modint(a) -= r; }
  constexpr modint operator*(const modint r) const { return modint(a) *= r; }
  constexpr modint operator/(const modint r) const { return modint(a) /= r; }
  constexpr bool operator!=(const modint r) const { return a != r.value(); }
};

template<const i64 M> std::ostream& operator<<(std::ostream& os, const modint<M>& m) { os << m.value(); return os; }

#include <vector>
#include <tuple>
using i64 = long long;

template<class T>
std::tuple<std::vector<T>, std::vector<T>> build_factorial(int N) {
  std::vector<T> fact(N);
  std::vector<T> finv(N);
  fact[0] = T(1);
  for(int i = 1;i < N;i++) {
    fact[i] = fact[i - 1] * T(i);
  }
  finv[N - 1] = T(1) / fact[N - 1];
  for(int i = N - 1; i --> 0;) {
    finv[i] = finv[i + 1] * T(i + 1);
  }
  return std::make_tuple(std::move(fact), std::move(finv));
}

const int mod = 1000003;
using fp = modint<mod>;

int main() {
  i64 Q;
  cin >> Q;
  vector<fp> fact, finv;
  std::tie(fact, finv) = build_factorial<fp>(mod);

  auto solve = [&](i64 x, i64 n) {
    if(x == 0 || x + n - 1 >= mod) return fp(0);
    return fact[x + n - 1] * finv[x - 1];
  };

  while(Q--) {
    i64 x, d, n;
    cin >> x >> d >> n;
    if(d == 0) {
      cout << fp(x).pow(n) << endl;
    }
    else {
      cout << solve((fp(x)/fp(d)).value(), n) * fp(d).pow(n) << endl;
    }
  }
}


Measured memory_bytes: 16512
n,k=map(int,raw_input().split())
p=[raw_input() for _ in xrange(n)]
cnt=0
pr=[0]*26

for i in xrange(n):
    pr[ord(p[i][0])-ord('A')]+=1

for i in xrange(26):
    if pr[i]>0:
        cnt+=1
if k>cnt:
    print(0)
else:
    ans=0
    while pr!=[0]*26:
        pr.sort()
        pr.reverse()
        tmp=k
        for i in xrange(26):
            if tmp==0:
                ans+=1
                break
            if pr[i]>0:
                tmp-=1
                pr[i]-=1
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll c[300005];
vector<ll>r[300005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m,H,W;
	vector<pll>v;
	cin >> H >> W >> m;
	ll mx=0;
	for(i=1;i<=m;i++)
	{
		cin >> x >> y;
		c[y]++;
		r[x].pb(y);
		mx=max(mx,x);
	}
	ll ans=0;
	
	multiset<ll>s;	
	for(i=1;i<=300000;i++)
	{
		// if(i==2)
		// 	cout<<c[i]<<endl;
		s.insert(-c[i]);
	}

	for(i=1;i<=300000;i++)
	{
		for(auto it:r[i])
		{
			// if(i==1)
			// 	cout<<it<<endl;
			s.erase(s.find(-c[it]));
			c[it]--;
			s.insert(-c[it]);
		}

		ans=max(ans,-(*(s.begin())) + sz(r[i]));
		
		for(auto it:r[i])
		{
			s.erase(s.find(-c[it]));
			c[it]++;
			s.insert(-c[it]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 36416