akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		int string_count = sc.nextInt();

		String[] strings = new String[string_count];

		for(int i = 0;i < string_count;i++){
			strings[i] = sc.next();
		}

		int[] min_alphabet_count = new int[26];
		for(int i = 0; i < 26;i++){
			min_alphabet_count[i] = Integer.MAX_VALUE;
		}

		for(int i = 0;i < strings.length;i++){
			String str = strings[i];
			for(int j = 0;j < 26;j++){
				int c = count(str,(char)('a' + j));
				if(c < min_alphabet_count[j])min_alphabet_count[j] = c;
			}
		}

		for(int i = 0;i < min_alphabet_count.length;i++){
			int cnt = min_alphabet_count[i];
			String str = String.valueOf((char)('a' + i));
			for(int j = 0;j < cnt;j++){
				System.out.print(str);
			}
		}
		System.out.println();

		sc.close();
	}

	static int count(String str,char ch){
		int cnt = 0;

		for(int i = 0;i < str.length();i++){
			if(str.charAt(i) == ch)cnt++;
		}

		return cnt;
	}
}


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

int main(){
  int w;


  while(cin >> w , w != -1){

    int k = 1150;
    if(w <= 10){
      cout << 4280 - k << endl;
    }
    if(w > 10){
      for(int i = 0; i < min(w-10, 10) ; i++){
	k += 125;
      }
    }
    if(w > 20){
      for(int i = 0; i < min(w-20, 10)  ; i++){
	k += 140;
      }
    }
    if(w > 30){
      for(int i = 0; i < w-30 ; i++){
	k += 160;
      }
    }
    if(w > 10) cout << 4280-k << endl;


  }

  return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll ans=0ll;
  cin>>N;
  vector<int> A(N);
  REP(i,N)cin>>A[i];

  ll right=0ll;
  ll sum=0ll;
  REP(left,N){
    while(right<N&&((sum^A[right])==sum+A[right])){
      sum=sum^A[right];
      right++;
    }
    ans+=right-left;
    if(right==left){
      right++;
    }else{
      sum=sum^A[left];
    }
  }
  cout<<ans<<endl;
}


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

int main() {
	int num;
	cin>>num;
	int a[200000];
	for(int i=0;i<num;i++){
	    cin>>a[i];
	}
	int max;
	int b[200000];
	int m=0;
	int n=0;
	for(int i=0;i<num;i++){
	    if(a[i]>m){
	        m=a[i];
	        n=i;
	    }
	}
	int p=0;
	for(int i=0;i<num;i++){
	    if(a[i]>p&&i!=n){
	        p=a[i];
	       // p=i;
	       // n=i;
	    }
	}
	for(int i=0;i<num;i++){
	    b[i]=m;
	}
	b[n]=p;

	for(int i=0;i<num;i++){
	    cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define sz(a) ((int)a.size())
#define pb push_back
#define lson (rt << 1)
#define rson (rt << 1 | 1)
#define gmid (l + r >> 1)
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

vector<int> G[maxn];
int n, m;

struct SegTree{

    int mx[maxn << 2], add[maxn << 2];
    void pushUp(int rt){

        mx[rt] = max(mx[lson], mx[rson]);
    }
    void build(int l, int r, int rt){

        if(l == r){

            mx[rt] = r;
            return;
        }
        int mid = gmid;
        build(l, mid, lson);
        build(mid + 1, r, rson);
        pushUp(rt);
    }
    void pushDown(int rt){

        if(add[rt]){

            add[lson] += add[rt], add[rson] += add[rt];
            mx[lson] += add[rt], mx[rson] += add[rt];
            add[rt] = 0;
        }
    }
    void update(int l, int r, int rt, int L, int R, int val){

        if(l >= L && r <= R){

            mx[rt] += val, add[rt] += val;
            return;
        }
        int mid = gmid;
        pushDown(rt);
        if(L <= mid) update(l, mid, lson, L, R, val);
        if(R > mid) update(mid + 1, r, rson, L, R, val);
        pushUp(rt);
    }
    int query(int l, int r, int rt, int L, int R){

        if(l >= L && r <= R) return mx[rt];
        int mid = gmid, ret = -inf;
        pushDown(rt);
        if(L <= mid) ret = max(ret, query(l, mid, lson, L, R));
        if(R > mid) ret = max(ret, query(mid + 1, r, rson, L, R));
        return ret;
    }
} tr;

int main(){

    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){

        int l, r; cin >> l >> r;
        G[l].pb(r);
    }
    tr.build(1, m + 1, 1);
    int ret = 0;
    for(int i = 0; i <= m; ++i){

        for(auto &r : G[i]){

            tr.update(1, m + 1, 1, 1, r, 1);
        }
        int tmp = tr.query(1, m + 1, 1, i + 1, m + 1);
        ret = max(ret, tmp - (m + i + 1));
    }
    ret = max(ret, n - m);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 14848
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}

int main(void){

  long n;
  scanf("%ld\n", &n);
  char s[n][11];
  for (long i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  qsort(s, n, sizeof(s[0]), cmp_s);
  long count = 1;
  for (long i = 1; i < n; i++) {
    if (strcmp(s[i-1],s[i]) != 0) {
      count++;
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 5716
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <vector>
#include <sstream>
#include <stack>
#include <queue>
#include <cmath>
using namespace std; 
int main() 
{  
    long long a[100005];
    long long n, t, t1=0;
    cin >> n;
    for (long long int i = 0; i<n; i++){
    	scanf("%lld", &a[i]);
	}
	for (long long int i = 0; i<n; i++){
		if (a[i]==i+1){
		    t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			t1++;
		}
	}
	cout << t1;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}


//全てのTの最小公倍数を求める
//2数A,BのLCMはA*B/GCD
//12,18,24
//隣り合う2数Ti,Ti+1のLCMを求める操作を繰り返す

int main() {
    ll N;
	cin >> N;
	vector<ll> T(N);
	for(ll i = 0;i<N;i++){
		cin >> T[i];
	}
	if(N == 1) cout << T[0] << endl;
    else{
	ll ans = (T[0]/gcd(T[0],T[1]))*T[1];
	for(ll i = 2;i<N;i++){
     ans = (ans/gcd(ans,T[i]))*T[i];
	}
	cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


int main()
{

  string S;
  cin >> S;

  for(int i = 0; i < S.length(); i++){
    if(i % 2 == 1){
      if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D'){
        cout << "No" << endl;

        return 0;
      }
    }
    else if(i % 2 == 0){
      if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D'){
        cout << "No" << endl;

        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
n = STDIN.gets.to_i
allsuit="SHCD"
arr=Array.new(52)
n.times {
  card=STDIN.gets.split
  suit=allsuit.index(card[0])
  num =card[1].to_i-1
  #printf("%d\n",suit*13+num)
  arr[suit*13+num]=1
}

0.upto(3) {|i|
  0.upto(12) {|j|
    printf("%s %d\n",allsuit[i],j+1) if arr[i*13+j]!=1
  }
}

Measured memory_bytes: 8604
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    if a.count(0) == n:
        print("Yes")
    else:
        if n % 3 == 0:
            s = list(set(a))
            if len(s) == 3:
                if s[0] ^ s[2] == s[1] and s[1] ^ s[0] == s[2] and s[2] ^ s[1] == s[0]:
                    if a.count(s[0]) == a.count(s[1]) == a.count(s[2]):
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
            elif len(s) == 2:
                if a.count(0) == n // 3:
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 94096
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Bouquet solver = new Bouquet();
        solver.solve(1, in, out);
        out.close();
    }

    static class Bouquet {
        public static long MOD = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();

            long result = modPow(2, n, MOD) - 1;
            result = modSub(result, com(n, a, MOD), MOD);
            result = modSub(result, com(n, b, MOD), MOD);
            out.println(result % MOD);
        }

        static long modSub(long x, long n, long mod) {
            long v = x - n;
            if (v < 0) {
                v += mod;
            }
            return v % mod;
        }

        static long modPow(long x, long n, long mod) {
            if (n == 0) {
                return 1;
            }
            long result = modPow(x, n / 2, mod);

            if (n % 2 == 0) {
                return (result * result) % mod;
            }
            return (((result * result) % mod) * x) % mod;
        }

        static long modInv(long a, long mod) {
            return modPow(a, mod - 2, mod);
        }

        static long modDiv(long a, long b, long mod) {
            return a * modInv(b, mod) % mod;
        }

        static long com(long n, long k, long mod) {

            long result = 1;
            for (int i = 0; i < k; i++) {
                result = (result * (n - i)) % mod;
                result = modDiv(result, i + 1, mod);
            }
            return result;
        }

    }
}



Measured memory_bytes: 35904
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++) {
        if(i%3==0)
            printf(" %d",i);
        else if(i/10%10==3)
            printf(" %d",i);
        else if(i%10==3)
            printf(" %d",i);
        else if(i/100%10==3)
            printf(" %d",i);
        else if(i%100==3)
            printf(" %d",i);
        else if(i/1000%10==3)
            printf(" %d",i);
        else if(i%1000==3)
            printf(" %d",i);
        else if(i/10000%10==3)
            printf(" %d",i);
        else if(i%10000==3)
            printf(" %d",i);
        }
        printf("\n");
    return 0;
} 


Measured memory_bytes: 2124
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,k;
bool flag=0;
int main()
{

    cin >> a >> b >> c >> d >> e >> k;
    if(a<b&&b<c&&c<d&&d<e){
        if((b-a<=k)&&(c-a<=k)&&(d-a<=k)&&(e-a<=k)){
            if((c-b<=k)&&(d-b<=k)&&(e-b<=k)){
                if((d-c<=k)&&(e-c<=k)){
                    if((e-d<=k)){
                        flag=1;
                    }
                }
            }
        }
    }
    if(flag==1) printf("Yay!");
    else printf(":(");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string in, s;
	cin >> in;
	cin >> s;
	cin >> in;
	cout << "A";
	cout << s[0];
	cout << "C";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20  
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (int)1e9+2
# define maxn 100006
# define offset 1005

/*************************************************
struct Coupon {
    ll l;
    ll r;
    ll id;

    Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

    bool operator<(const Coupon& c) { // Sorting
        return l < c.l;    
    }
};

**************************************************/

int cl[maxn];
int dist[maxn];

vector<int>g[maxn];
bool vis[maxn];

void solve(int x,int d,int c)
{
   if(cl[x]==0)
   {
     cl[x]=c;
   }
   if(dist[x]>=d)//this condition says that already an v was vis when a greater radius was visited so no need to vis this time 
     return;
   dist[x]=d;
   if(d==0)
    return;
   for(int i=0;i<g[x].size();i++)
   {
     solve(g[x][i],d-1,c);
   }
}


int main()
{
  IOS;
  int n,m;
  cin >> n >> m;
  int a,b;

  for(int i=0;i<m;i++)
  {
     cin >> a >> b;
     g[a].pb(b);
     g[b].pb(a);
  }
  int q;
  cin >> q;
  int v[q],c[q],d[q];
  for(int i=0;i<q;i++)
  {
     cin >> v[i] >> d[i] >> c[i];
  }

  for(int i=q-1;i>=0;i--)
  {
    solve(v[i],d[i],c[i]);
  }

  for(int i=1;i<=n;i++)
     cout << cl[i]<<"\n";
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) (x).begin(),(x).end()
#define int ll

#define pt pair<int, int>
#define x first
#define y second

const int MOD = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

int mul(int a, int b) {
	return (ll) a * b % MOD;
}

const int MAXN = 3010;
int n, s;
int a[MAXN];
int pows[MAXN];

void precalc() {
	pows[0] = 1;
	for (int i = 1; i < MAXN; i++)
		pows[i] = mul(2, pows[i - 1]);
}

int dp[MAXN];

void solve() {
	precalc();
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int ans = 0;
	for (int l = 1; l <= n; l++) {
		for (int r = l; r <= n; r++) {
			int len = r - l + 1;
			ans = add(ans, sub(pows[len], 1));
		}
	}
	//cout << ans << endl;
	for (int i = 0; i < MAXN; i++)
		dp[i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int w = s + 1; w >= 1; w--) {
			int nxt = w + a[i];
			if (nxt > s + 1) nxt = s + 1;
			dp[nxt] = add(dp[nxt], dp[w]);
		}
		int nxt = a[i];
		if (nxt > s + 1) nxt = s + 1;
		dp[nxt] = add(dp[nxt], i);
		for (int w = 1; w <= s + 1; w++) {
			if (w == s) continue;
			ans = sub(ans, dp[w]);
		}
	}
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.precision(20);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 512
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,q = readline() |> split |> parseMap
	e = [Int[] for i in 1:n]
	t = zeros(Int,n)
	t[1] = -1
	for i in 1:n-1
		a,b = readline() |> split |> parseMap
		push!(e[a],b)
		push!(e[b],a)
	end
	stack = Int[1]
	c = zeros(Int,n)
	for i in 1:q
		p,x = readline() |> split |> parseMap
		c[p]+=x
	end
	total = zeros(Int,n)
	while !isempty(stack)
		now = pop!(stack)
		for i in 1:length(e[now])
			if t[e[now][i]] == 0
				t[e[now][i]] = now
				c[e[now][i]] += c[now]
				push!(stack, e[now][i])
			end
		end
	end
	for i in 1:n-1
        print(c[i], " ")
    end
    println(c[n])
end

main()

Measured memory_bytes: 180732
#include<bits/stdc++.h>
#define inf 1e9+7
#define ll long long
#define clr(c) memset(c,0,sizeof(c))
const int M=2e5+10;
const int N=1e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1; char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-48; c=getchar();}
	return b*sum;
}
ll n,m,b,k;
ll a[M],sum[M];
int main()	
{	
	ll i,j;
	n=read();k=read();
	for(i=1;i<=n;i++)
	{
		a[i]=read()+1;
		sum[i]=sum[i-1]+a[i];
	}
	ll ans=0;
	for(i=0;i+k<=n;i++)
	{
		ans=max(ans,sum[i+k]-sum[i]); 
	} 
	printf("%lf",(double)ans/2);
	return 0;
} 

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
void fun(){
	ll n,m,k,ans=0;
	cin>>n>>m>>k;
	ll a[n],b[m];
	fi(0,n)	cin>>a[i];
	fi(0,m)	cin>>b[i];
	ll sum=0,j=0;
	fi(0,n){
		if(sum+a[i]>k)
			break;
		sum+=a[i];
		j=i+1;
	}
	ans=j;
	fi(0,m){
		while(j>=0&&sum+b[i]>k){
			sum-=a[--j];
		}
		sum+=b[i];
		ans=max(ans,j+i+1);
		if(j<0)	
			break;
	}
	cout<<ans;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		fun();
	}
}

Measured memory_bytes: 6732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            int[] c_list = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            List<int[]> s_list = new List<int[]>();
            List<int> last_list = new List<int>();
            List<int> value_list = new List<int>();

            for (int i = 0; i < D; i++)
            {
                int[] s_array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                s_list.Add(s_array);
            }

            for (int i = 0; i < 26; i++)
            {
                last_list.Add(0);
                value_list.Add(0);
            }

            for (int i = 1; i <= D; i++)
            {
                List<int[]> temp_list = new List<int[]>();
                List<int> sum_list = new List<int>();

                for (int j = 0; j < 26; j++)
                {
                    temp_list.Add(new int[26]);
                }

                for (int j = 0; j < 26; j++)
                {
                    for (int k = 0; k < 26; k++)
                    {
                        if (k == j)
                        {
                            temp_list[j][k] = value_list[k] + s_list[i - 1][k];
                        }
                        else
                        {
                            temp_list[j][k] = value_list[k] - c_list[k] * (i - last_list[k]);
                        }
                    }
                }

                int max_index = 0;
                int max = temp_list[0].Sum();

                for (int j = 1; j < 26; j++)
                {
                    int temp_sum = temp_list[j].Sum();
                    if (max < temp_sum)
                    {
                        max_index = j;
                        max = temp_sum;
                    }
                }

                Console.WriteLine(max_index + 1);
                value_list = temp_list[max_index].ToList();
                last_list[max_index] = i;
            }
        }
    }
}


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

int main() {
	int N, K, d, a;

	cin >> N >> K;

	vector<int> vec(N, 0);

	for (int i = 0; i < K; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> a;
			vec.at(a - 1) = 1;
		}
	}

	int output = 0;

	for (int i = 0; i < N; i++) {
		if (vec.at(i) == 0) {
			output++;
		}
	}

	cout << output << endl;

	return 0;
}


Measured memory_bytes: 3612
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2020 , P = 1e9 + 7;
int comb[N][N] , f[N][N] , sum[N][N] , A , B;
inline void pp(int &x,int d){if((x+=d)>=P)x-=P;}
inline int add(int a,int b){return (a+b)%P;}
inline int mul(int a,int b){return ll(a)*b%P;}

int main(){
    rep(i,0,N) rep(j,0,i+1) comb[i][j] = j ? add(comb[i-1][j-1] , comb[i-1][j]) : 1;
    rep(i,0,N) rep(j,0,i+1) sum[i][j] = add(j ? sum[i][j-1] : 0 , comb[i][j]);
    cin >> A >> B;
    rep(i,0,N) f[i][0] = f[0][i] = 1;
    rep(i,1,A+1) rep(j,1,B+1) f[i][j] = add(f[i-1][j] , sum[j-1][min(i,j-1)]);
    int ans = 0;
    rep(i,0,A+1) for(int j=0;i+j<=A&&j<B;++j)
        pp(ans,mul(f[i][j] , comb[B-1][j]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47232
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
#define REP(i,n) for (ll i=1;i<=n;i++)
using namespace std;
 
ll n,m;
ll x[110000];
ll y[110000];
 
int main() {
  cin>>n>>m;
  rep(i,m) cin>>x[i]>>y[i];
  vector<bool> red(n+1,false);
  vector<ll> ball(n+1,1);
  red[1]=true;
  rep(i,m) {
    if (red[x[i]]) {
      if (ball[x[i]]==1) {
        ball[x[i]]--;
        red[x[i]]=false;
        ball[y[i]]++;
        red[y[i]]=true;
      }
      else {
        ball[x[i]]--;
        red[x[i]]=true;
        ball[y[i]]++;
        red[y[i]]=true;
      }
    }
    else {
      ball[x[i]]--;
      ball[y[i]]++;
    }
  }
  ll ans=0;
  REP(i,n) {
    if (red[i]) {
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2560
n = gets.to_i
s = gets.chomp

answer = "Yes"
if n % 2 == 1
  answer = "No"
else
  n_half = n / 2
  t1 = s[0, n_half]
  t2 = s[n_half, n_half]
  unless t1 == t2
    answer = "No"
  end
end
puts answer

Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
	int H, W;
	while (scanf("%d%d", &H, &W) == 2 && (H|W) != 0) {
		int i, j;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) putchar('#');
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2140
import heapq

def main():
    n, m = map(int, input().split())
    a = [int(i) for i in input().split()]
    ans = solve(n, m, a)
    print(ans)


def solve(n, m, a):
    a = list(map(lambda x: -x, a))
    heapq.heapify(a)
    #print(a)
    for i in range(m):
        x = heapq.heappop(a)
        heapq.heappush(a, -((-x) // 2))
        #print(a)
    a = list(map(lambda x: -x, a))
    #print(a)
    return sum(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14992
def main():
  from collections import defaultdict
  from collections import Counter
  
  n = int(input())
  a = list(map(int, input().split()))
  
  d = Counter(a)
  e = defaultdict(int)
  
  func = lambda x: x*(x-1)//2 if x>=2 else 0
  v = list(d.values())
  base = sum(list(map(func, v)))
  
  for k,v in d.items():
    if v<=1:
      e[k] = base - 0
    else:
      e[k] = base - ( v*(v-1)//2 - (v-1)*(v-2)//2 )
    
  p = [str(e[x])+'\n' for x in a]
  q = ''.join(p)
  print(q)
      
 
if __name__=='__main__':
    main()


Measured memory_bytes: 119372
#include<bits/stdc++.h>                          
using namespace std;
int x,a,b,c,sum;
int main(){
    cin>>a>>b>>c>>x;
    x/=50;
    for(int i=0;i<=a;i++)
	{
        for(int j=0;j<=b;j++)
		{
            for(int k=0;k<=c;k++)
                if(i*10+j*2+k==x) sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

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

int main(){
  long long a, b;
  cin >> a >> b;
  
  // a =< b となるようにする
  if(a>b){
    long long c = b;
    b = a;
    a = c;
  }
    
  long long res;
  for(int i=1; i<a+1; i++){
    long long bi = b*i;
    if(bi % a == 0){
      res = bi;
      break;
    }
  }
  
  cout << res << endl;
  
  return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<vector<int>>vec(n, vector<int>(3, 0));
	
	for(int i=0;i<n;i++)
		cin>>vec[i][0]>>vec[i][1]>>vec[i][2];
		
	vector<vector<int>>dp(n, vector<int>(3, 0));
	dp[0][0]=vec[0][0];
	dp[0][1]=vec[0][1];
	dp[0][2]=vec[0][2];
	for(int i=1;i<n;i++) {
		dp[i][0]=vec[i][0]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]=vec[i][1]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]=vec[i][2]+max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

Measured memory_bytes: 11136
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[]
e=0
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    d=0
    for j in range(m):
        d+=a[i][j]*b[j]
    if d+c>0:
        e+=1
print(e)

Measured memory_bytes: 3060
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
s=input()
k=int(input())
n=len(s)
a=[chr(i) for i in range(ord('a'),ord('z')+1)]
ans=set()
for i in a:
    if i not in s:
        continue
    if len(ans)>=5:
        break
    for c in range(n):
      if s[c]==i:
          l=c
          r=c
          while True:
            if  r>n or r-l>6:
                break
            ans.add(s[l:r+1])
            r+=1
ans=list(ans)
ans.sort()
print(ans[k-1])


Measured memory_bytes: 69500
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vl dp(n+1);  // dp[i+1] : i日目に株の売却が終了した時点での所持金の最大値
    dp[0] = 1000;
    rep(i, n) {
        chmax(dp[i+1], dp[i]);
        rep(j, i) {
            chmax(dp[i+1], (dp[j]/a[j])*a[i] + dp[j]%a[j]);
        }
    }
    
    out(dp[n]);
    re0;
}

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

int main() {
    int N, W;
    cin >> N >> W;
    int value[N], weight[N];
    for (int i = 0; i < N; i++) cin >> value[i] >> weight[i];

    // dp[i + 1][w] := i番目までの品物の中から重さがwを超えないように選んだ時の価値の総和の最大値
    int dp[110][10010];
    // dpテーブルの初期化
    // 品物を選択していない状態
    for (int i = 0; i <= W; i++) dp[0][i] = 0;
    // 選択
    for (int i = 0; i < N; i++) {
        for (int w = 0; w <= W; w++) {
            if (w >= weight[i]) {
                // 重さ的に品物を選択することができる
                dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
            } else {
                // 選択できない
                dp[i + 1][w] = dp[i][w];
            }
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7032
A, B, C = sorted([int(x) for x in input().split()])

def solve(A, B, C):
    # C - A, C - B
    # odd    even
    # even   even
    # even   odd
    count = 0

    if A < B:
        if (B-A)% 2 == 0:
            count += (B-A)//2
            A = B
            # A == B <= C
        else:
            A += 1
            assert (B-A) % 2 == 0
            C += 1
            count += 1
            count += (B-A)//2
            A = B
    assert A == B
    if B < C:
        count += (C-B)

    return count

print(solve(A, B, C))


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef struct{
  char sub;
  int figure;
  int order;
}card;
int partition(card*,int,int);
void quicksort(card*,int,int);
void swap(card*,int,int);
bool stablenor(card*,int);
int main(){
  int n,i,temp,r,l,flag=0;
  int *stablejudge;
  card *list;
  scanf("%d",&n);
  list=(card*)malloc(n*sizeof(card));
for(i=0;i<n;i++){
  scanf("%*c%c%d",&((list+i)->sub),&((list+i)->figure));
  ((list+i)->order)=i;
}
  r=n-1;
  l=0;
quicksort(list,l,r);
printf("%s\n",(stablenor(list,n)!=true)?"Not stable":"Stable");
  for(i=0;i<n;i++)printf("%c %d\n",((list+i)->sub),((list+i)->figure));
  return 0;
}
int partition(card *l,int left,int right){
int i;
  for(i=left;i<right;i++){
    if((l+right)->figure>=(l+i)->figure){
      swap(l,i,left);
      left++;
    }
  }
  swap(l,left,right);
  return left;
}
void quicksort(card *l,int left,int right){
int q;
  if(left<right){
    q=partition(l,left,right);
    quicksort(l,left,q-1);
    quicksort(l,q+1,right);
  }
}
void swap(card *x,int a,int b){
  card c;
  c=*(x+a);
  *(x+a)=*(x+b);
  *(x+b)=c;
}
bool stablenor(card *l,int n){
  while(n-1){
    if(((l+(n-2))->figure)==((l+(n-1))->figure)&&((l+(n-2))->order)>((l+(n-1))->order))return false;
    n--;
  }
  return true;
}



Measured memory_bytes: 2860
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d=[list(map(int,input().split())) for i in range(n)]

for i in range(n-2):
    d11,d12=d[i]
    d21,d22=d[i+1]
    d31,d32=d[i+2]
    if d11==d12 and d21==d22 and d31==d32:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 68152
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  string s;
string ans;
  cin >> s;
rep(i,SZ(s)){
if(s.at(i) != 'B'){
ans += s.at(i);
}else if(!ans.empty()){
ans.pop_back();
}
}
//   for(int i =0 ; i<SZ(s);i++){
//     if(i ==0 && s.at(i) == 'B'){
// s.erase(i,1);
// i = -1;
//     }
//     if(i > 0&&s.at(i) == 'B'){
//       s.erase(i - 1,2);
//       i = -1;
//     }
//   }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>

typedef long long ll;

using namespace std;

void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

int main(){

    ll n;
    cin>>n;
    map<ll,ll> mp;

    const ll MOD = 1000000007;

    ll ans=1;

    for(ll i=1;i<=n;i++){
        factoring(i, mp);
    }

    for(auto i:mp){
        ans*=(i.second+1);
        ans%=MOD;
	}
    
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

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

	 int x = 0;

	 loop(i,0,n)
	 {
	 	cin >> A[i];
	 	x ^= A[i];
	 }

	 loop(i,0,n)
	 {
	 	cout << (x^A[i]) << " ";
	 }

}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 5224
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int f(int h){
    return h==1?1:2*f(h/2)+1;
}

void run(){
    int h;
    cin>>h;
    cout<<f(h)<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = input()
X = input().rstrip().split(' ')

n = int(n)
x = [0 for _ in range(n)]

for a in range(n):
    x[a] = int(X[a])
    
x.sort()

count = 1000000
tei = 0

for a in range(100):
    tei = 0
    for b in x:
        tei += (b-a)**2
    count = min(tei,count)
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m,r;
  cin>>n>>m>>r;
  vi R(r);
  rep(i,r){
    cin>>R[i];
    R[i]--;
  }
  int d[200][200];
  rep(i,n)rep(j,n){
    if(i==j)d[i][j] = 0;
    else d[i][j] = 100100101;
  }
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    d[a][b]=c;
    d[b][a] = c;
  }
  rep(k,n){
    rep(i,n){
      rep(j,n){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  sort(rng(R));
  int ans = INT_MAX;
  do{
    int cost = 0;
    int tmp = 0;
    for(auto e:R){
      cost+=d[tmp][e];
      tmp = e;
    }
    cost-=d[0][R[0]];
    mins(ans,cost);
  }while(next_permutation(rng(R)));
  print(ans);
  return 0;
}

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


int main(){
    int64_t n;

    cin >> n;
    vector<int> vec(n-1);
    vector<int> ans(n, 0);

    for (int i = 0; i < n - 1; i++) cin >> vec.at(i);
    for (int i = 0; i < n - 1 ; i++) ans.at(vec.at(i)-1)++;
    for (int i = 0; i < n; i++) cout << ans.at(i) << endl;

}

Measured memory_bytes: 4716
MOD = 10**9+7

n = int(input())
s = bin(n)[2:]
l = len(s)
dp = [[0]*4 for i in range(l+1)]
dp[0][0] = 1

for i in range(l):
    b = 1 if s[i] == '1' else 0
    for j in range(4):
        for k in range(3):
            lj = min((j<<1) + b - k, 3)
            if 0 <= lj:
                dp[i+1][lj] += dp[i][j]
                dp[i+1][lj] %= MOD

# print(dp)
print(sum(dp[l])%MOD)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,M;
    cin>>N>>M;
    vector<LP> AB(N);
    rep(i,N){
        cin>>AB.at(i).first>>AB.at(i).second;
    }
    sort(AB.begin(),AB.end());
    ll ans=0;
    int now=0;
    int po=0;
    while(po<N && now+AB.at(po).second<=M){
        ans+=AB.at(po).first*AB.at(po).second;
        now+=AB.at(po).second;
        po++;
    }
    if(now<M)ans+=AB.at(po).first*(M-now);
    cout<<ans<<endl;
}

Measured memory_bytes: 4820
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in= new Scanner(System.in);
		while(in.hasNext())
		{
			String st[]=in.nextLine().split(" ");
			if(st[0].equals("0"))
				return;
			ArrayList<Integer> a=new ArrayList<Integer>();
			ArrayList<Integer> o=new ArrayList<Integer>();
			for(int i=0;i<st.length;i++)
			{
				if(st[i].equals("1"))
					o.add(Integer.valueOf(st[i]));
				else
					a.add(Integer.valueOf(st[i]));
			}	
			int sum=0;
			for(int i=0;i<a.size();i++)
			{
				if(a.get(i)>=10)
					sum+=10;
				else
					sum+=a.get(i);
			}
			for(int i=0;i<o.size();i++)
				sum+=11;
			for(int i=0;i<o.size();i++)
			{
				if(sum>21)
				{
					sum-=10;
				}
				else
					break;
			}
			if(sum>21)
				sum=0;
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#define MAX 100000

using namespace std;

bool isPrime[MAX];

void is_Prime(void){

  for( int i = 0 ; i < MAX ; i++ )
    isPrime[i] = true;

  isPrime[0] = isPrime[1] = false;

  for( int i = 0 ; i*i < MAX ; i++ ){
    if(isPrime[i]){
      for( int j = 2*i ; j < MAX ; j += i ){
	isPrime[j] = false;
      }
    }
  }
}

int main(void){

  is_Prime();

  int n;
  while( cin >> n ){
    int cnt = 0;
    for( int i = 1 ; i <= n ; i++ ){
      if( isPrime[i] && isPrime[n + 1 - i] ) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
S = input()

def f(a, b, s):
    if a in s and b in s:
        return True
    elif not a in s and not b in s:
        return True
    else:
        return False

if f('N', 'S', S) and f('W', 'E', S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;


string toString(int n)
{
	string str;
	stringstream ss;
	ss << n;
	ss >> str;
	return str;
}
string toNegativeBase(int n, int negBase)
{
	//  If n is zero then in any base it will be 0 only
	if (n == 0)
		return "0";

	string converted = "";
	while (n != 0)
	{
		// Get remainder by negative base, it can be
		// negative also
		int remainder = n % negBase;
		n /= negBase;

		// if remainder is negative, add abs(base) to
		// it and add 1 to n
		if (remainder < 0)
		{
			remainder += (-negBase);
			n += 1;
		}

		// convert remainder to string add into the result
		converted = toString(remainder) + converted;
	}

	return converted;
}

//  Driver code to test above methods
int main()
{
	int n;
	int negBase = -2;
	cin >> n;
	cout << toNegativeBase(n, negBase) << "\n";

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n = int(input())
s = input()
ans = 1

for p in range(1, n):
  if s[p - 1] != s[p]:
    ans += 1
print(ans)


Measured memory_bytes: 23016
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <complex>
#include <vector>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
typedef complex<double> P;
#define EPS (1e-10)

double cross(const P& a, const P& b) { return imag(conj(a)*b); }
double dot(const P& a, const P& b) { return real(conj(a)*b); }
int ccw(const P& a, P b, P c) {
    b -= a; c -= a;
    if(cross(b, c)>0) return 1;
    if(cross(b, c)<0) return -1;
    if(dot(b, c)<0) return 2;
    if(norm(b)<norm(c)) return -2;
    return 0;
}
P crosspoint(const P& l0, const P& l1, const P& m0, const P& m1) {
    const double a = cross(l1-l0, m1-m0);
    const double b = cross(l1-l0, l1-m0);
    if(abs(a)<EPS && abs(b)<EPS) return m0;
    return m0 + b/a*(m1-m0);
}
double polygon_size(const vector<P>& v) {
    double s = 0;
    rep(i, v.size()-2) s += cross(v[i+1]-v[0], v[i+2]-v[0]);
    return fabs(s)/2;
}
vector<P> convex_cut(const vector<P>& v, const P& l0, const P& l1) {
    vector<P> r;
    rep(i, v.size()) {
        const P &a(v[i]), &b(v[(i+1)%v.size()]);
        if(ccw(l0, l1, a)!=-1) r.push_back(a);
        if(ccw(l0, l1, a)*ccw(l0, l1, b)<0) {
            r.push_back(crosspoint(l0, l1, a, b));
        }
    }
    return r;
}

double size(const vector<P>& ps, const P& p) {
    return polygon_size(convex_cut(ps, p, P(0, 0)));
}

P solve(const vector<P>& ps) {
    const double H = polygon_size(ps) / 2;
    rep (i, ps.size()) {
        P a = ps[i], b = ps[(i+1)%ps.size()];
        if (size(ps, a) > size(ps, b)) swap(a, b);
        if (size(ps, a)-EPS <= H && H <= size(ps, b)+EPS) {
            double l = 0, r = 1;
            rep (_, 100) {
                const double mid = (l+r) / 2;
                if (size(ps, a+mid*(b-a)) < H) l = mid; else r = mid;
            }
            return a+l*(b-a);
        }
    }
    assert(false);
    return P(0, 0);
}

int main() {
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        vector<P> ps;
        rep(i, n) {
            int x, y;
            scanf("%d%d", &x, &y);
            ps.push_back(P(x, y));
        }
        const P p = solve(ps);
        printf("%.15f %.15f\n", p.real(), p.imag());
    }
}

Measured memory_bytes: 1096
s = input().replace('><', '> <').split()
ans = 0
for s_ in s:
    a = s_.count('<')
    b = len(s_) - a
    if a < b:
        ans += a * (a - 1) //  2
        ans += b * (b + 1) // 2
    else:
        ans += a * (a + 1) //  2
        ans += b * (b - 1) // 2
print(ans)



Measured memory_bytes: 57200
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cost[10]={0,2,5,5,4,5,6,3,7,6};
string dp[11000];

void chmax(string &s,string t){
    if(s=="-") s=t;
    else if(s.size()<t.size()) s=t;
    else if(s.size()==t.size()){
        if(s<t) s=t;
    }
}

signed main()
{
    int N,M; cin>>N>>M;
    vector<int> A(M);
    REP(i,M) cin>>A[i];

    REP(i,11000) dp[i]="-";
    dp[0]="";
    for(int i=0;i<=N;i++){
        if(dp[i]=="-") continue;
        for(auto a:A){
            string b=dp[i]+(char)('0'+a);
            chmax(dp[i+cost[a]],b);
        }
    }
    cout<<dp[N]<<endl;

}


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

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

const double pi = 3.141592653589793;


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

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

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

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

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

	return ans;
}


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



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

	int S = (2 * L + N - 1)*N / 2;
	int m;
	if (L >= 0) m = L;
	else if (L + N - 1 <= 0) m = L + N - 1;
	else m = 0;

	cout << S - m;

	return 0;
}


Measured memory_bytes: 256