akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = [int(i) for i in input().split()]

ans1 = 0
count = 0
for i in range(N):
  if i%2==0:
    if count+a[i]>=0:
      ans1 += a[i]+count+1
      count = -1
    else:
      count += a[i]
  else:
    if count+a[i]<=0:
      ans1 += abs(count)+1-a[i]
      count = 1
    else:
      count += a[i]    

count = 0
ans2 = 0
for i in range(N):
  if i%2==0:
    if count+a[i]<=0:
      ans2 += -a[i]+abs(count)+1
      count = 1
    else:
      count += a[i]
  else:
    if count+a[i]>=0:
      ans2 += count+1+a[i]
      count = -1
    else:
      count += a[i]
  

print(min(ans1, ans2))

Measured memory_bytes: 14468
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int A,B,K;
	cin >> A >> B >> K;
	int tmp = 0;
	for(int i=100; i>=1; i--){
		if(A%i == 0 && B%i == 0)tmp++;
		if(tmp == K){
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans = 1900 * (1 << m) * m + 100 * (1 << m) * (n - m);
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
a = input()
count = 0
for i in range(1, int(a) + 1):
    if i % 3 == 0 and i % 5 == 0:
        #print('FizzBuzz')
        count += 0
    elif i % 3 == 0:
        #print('Fizz')
        count += 0
    elif i % 5 == 0:
        #print('Buzz')
        count += 0
    else:
        count += i
        #print(i)

print(count)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[3005][3005];
int anss  = 0 ;
char rep[100005];
int c=0;
string str1,str2;
int lcs(int first,int last)
    {
        if(first<=0|last<=0)
            {
                return 0;
            }
        if(dp[first][last]!=-1)
            return dp[first][last];
        if(str1[first]==str2[last]&&(first!=str1.size()&&last!=str2.size()))
        {
            dp[first][last]=1+lcs(first-1,last-1);
            anss = max(anss,dp[first][last]);
 
        }
        else
            {
            dp[first][last] = max(dp[first][last],max(lcs(first-1,last),lcs(first,last-1)));
            }
        return dp[first][last];
 
    }
void printstring()
    {
        int i = str1.size();
        int j = str2.size();
        //int idx = anss;
        int idx=lcs(str1.size()-1,str2.size()-1);
        char str[anss+1];
        str[idx+1]='\0';
        while(i>0&&j>0)
        {
            if(str1[i]==str2[j])
            {
                str[idx]= str1[i];
                idx--;
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
        cout<<str<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    for(int i=0;i<3006;i++)
        for(int j=0;j<3006;j++)
            dp[i][j]=-1;
    cin>>str1>>str2;
    str1="X"+str1;
    str2="Y"+str2;
    string ans="";
    int n = min(str2.size(),str1.size());
    int n1 = max(str2.size(),str1.size());
    lcs(str1.size()-1,str2.size()-1);
    printstring();
 
}
 
 

Measured memory_bytes: 39244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int N = 100000 + 5;

int main()
{
	int t;
	cin >> t;
	double a = t / 3.00;
	double sum = a*a*a;
	printf("%.6lf\n",sum); 
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];


    sort(a.begin(), a.end(), greater<int>());

    vector<int> b = a;
    reverse(b.begin(), b.end());

    deque<int> align;

    int cnt = 0;
    int turn = 0;

    int indexa = 1;
    int indexb = 0;

    align.push_back(a[0]);
    turn = 1;
    cnt = 1;

    while(true){
        if(turn % 2 == 0){
            align.push_back(a[indexa++]);
        } else {
            align.push_back(b[indexb++]);
        }
        
        cnt++;
        if(cnt == n){
            break;
        }
        if(turn % 2 == 0){
            align.push_front(a[indexa++]);
        } else {
            align.push_front(b[indexb++]);
        }
        cnt++;
        turn++;
        if(cnt == n){
            break;
        }
    }

    ll ans1 = 0;
    for(int i = 0; i < n - 1; i++){
        ans1 += abs(align[i] - align[i + 1]);
    }

    align.clear();

    cnt = 0;
    turn = 0;
    indexa = 0;
    indexb = 1;

    align.push_back(b[0]);
    turn = 0;
    cnt = 1;

    while(true){
        if(turn % 2 == 0){
            align.push_back(a[indexa++]);
        } else {
            align.push_back(b[indexb++]);
        }
        
        cnt++;
        if(cnt == n){
            break;
        }
        if(turn % 2 == 0){
            align.push_front(a[indexa++]);
        } else {
            align.push_front(b[indexb++]);
        }
        cnt++;
        turn++;
        if(cnt == n){
            break;
        }
    }


    ll ans2 = 0;
    for(int i = 0; i < n - 1; i++){
        ans2 += abs(align[i] - align[i + 1]);
        // cout << align[i] << " ";
    }
    // cout << align[n - 1] << endl;

    cout << max(ans1, ans2) << endl;

}

Measured memory_bytes: 1408
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int p, q, r;
	cin >> p >> q >> r;

	int ans1 = p + q;
	int ans2 = r + p;
	int ans3 = r + q;
	cout << min(min(ans1, ans2), ans3) << endl;
	return 0;
}


Measured memory_bytes: 256
program divertaB
	integer R, G, B, N, M, count
    integer L1I, L2I, i, j, L1, L2, L3
    count = 0
    read(*, *) R, G, B, N
    L1 = MAX(R, G, B)
    L3 = min(R, G, B)
    L2 = R + G + B - L1 - L3
    L1I = int(N/L1) + 1
     DO 10 i = 0, L1I
     L2I = int((N-i)/L2) + 1
     if (L2I.GE.0) then
      DO 20 j = 0, L2I
        M = N - L1*i - L2*j
        if (M.GE.0) then
         if (mod(M, L3)==0) then
       count = count + 1
        end if
       end if
      20 continue
      end if
      10 continue
    print '(i0)', count
end program

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

int main() {
    ll S;
    cin >> S;
    ll x1 = 1000000000;
    cout << "0 0 " << x1 << " 1 ";
    ll y2 = (S-1) / x1 + 1;
    ll y1 = (y2 * x1) - S;
    cout << y1 << " " << y2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5+5;

int n, m, d[305][305];
multiset<int> s[MAXN];
vector<int> v;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		s[a].insert(b);
		s[b].insert(a);
	}
	for (int i = 0; i < n; ++i) {
		if (s[i].size()%2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (m >= n+100) {
		cout << "Yes" << endl;
		return 0;
	}
	if (m <= n+1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		if (s[i].size() == 2) {
			int x = *s[i].begin(), y = *s[i].rbegin();
			s[x].erase(s[x].find(i));
			s[y].erase(s[y].find(i));
			s[x].insert(y);
			s[y].insert(x);
		} else {
			v.push_back(i);
		}
	}
	m -= (n-v.size());
	n = v.size();
	map<int, int> y;
	int ct = 0;
	for (int i : v) {
		y[i] = ct;
		ct++;
	}

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			d[i][j] = 1000000;
	for (int i : v)
		for (int j : s[i])
			d[y[i]][y[j]] = 1;

	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	int mini = 1000000;
	for (int i = 0; i < n; ++i)
		mini = min(mini, d[i][i]);

	if (mini >= m-n) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 14336
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


public class my
{
	private static StringBuilder sb = new StringBuilder();
	
	public static void Main()
	{	
		int n = my.GetInt();
		
		LinkedList<int> dll = new LinkedList<int>();
		
		for(int i = 0; i < n; i++) {
			string order = Console.ReadLine();
			
			if(order.StartsWith("insert")) {
				dll.AddFirst( int.Parse( order.Split(' ')[1] ) );
			} else if (order == "deleteFirst") {
				dll.RemoveFirst();
			} else if (order == "deleteLast") {
				dll.RemoveLast();
			} else {
				dll.Remove( int.Parse( order.Split(' ')[1] ) );
			}
		}
		
		my.WriteArray(dll.ToArray());
	}
	
	private static void Flush()
	{
		Console.Write(sb);
		sb.Length = 0;
	}
	
	private static void AppendLine(int v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(long v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(string[] v)
	{
		sb.AppendLine(string.Join(" ", v));
	}
	
	private static void Swap(ref string a, ref string b) 
	{
		string tmp = a;
		a = b;
		b = tmp;
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

public class Node<T>
{
  T val;
  Node<T> prev;
  Node<T> next;

  internal Node(T val, Node<T> prev, Node<T> next)
  {
    this.val = val;
    this.prev = prev;
    this.next = next;
  }

  public T Value
  {
    get { return this.val; }
    set { this.val = value; }
  }

  public Node<T> Next
  {
    get { return this.next; }
    internal set { this.next = value; }
  }

  public Node<T> Previous
  {
    get { return this.prev; }
    internal set { this.prev = value; }
  }
}

Measured memory_bytes: 88924
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int cnt = 0;
    int max = 0;
    for(int i=0; i<N; i++){
      if(S.charAt(i)=='I'){
        cnt++;
      }else{
        cnt--;
      }
      max = Math.max(max, cnt);
    }
    System.out.println(max);
  }
}   
    

Measured memory_bytes: 35844
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>  //for bool
#include <stdlib.h> // abs,labs,llabs
#include <limits.h>
#include <ctype.h>

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf

int main(void) {
  int n, i;
  float ans = 0.0, x;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%f", &x);
    ans += 1 / (float)x;
  }
  printf("%f\n", (1 / (float)ans));
  return 0;
}


Measured memory_bytes: 256
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])
    for i in range(2, n):
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
    print(dp[-1])


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 13928
c0 = gets.chomp.split(" ").map(&:to_i)
c1 = gets.chomp.split(" ").map(&:to_i)
c2 = gets.chomp.split(" ").map(&:to_i)

a01 = c0[0] - c0[1]
a02 = c0[0] - c0[2]
a12 = c0[1] - c0[2]
if c1[0] - c1[1] != a01 then
  puts "No"
  exit
end
if c1[0] - c1[2] != a02 then
  puts "No"
  exit
end
if c1[1] - c1[2] != a12 then
  puts "No"
  exit
end
if c2[0] - c2[1] != a01 then
  puts "No"
  exit
end
if c2[0] - c2[2] != a02 then
  puts "No"
  exit
end
if c2[1] - c2[2] != a12 then
  puts "No"
  exit
end
b01 = c0[0] - c1[0]
b02 = c0[0] - c2[0]
b12 = c1[0] - c2[0]
if c0[1] - c1[1] != b01 then
  puts "No"
  exit
end
if c0[1] - c2[1] != b02 then
  puts "No"
  exit
end
if c1[1] - c2[1] != b12 then
  puts "No"
  exit
end
if c0[2] - c1[2] != b01 then
  puts "No"
  exit
end
if c0[2] - c2[2] != b02 then
  puts "No"
  exit
end
if c1[2] - c2[2] != b12 then
  puts "No"
  exit
end
puts "Yes"

Measured memory_bytes: 1788
// <------------- Template -----------------------> //

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;
// <------------- Implement Functions Here ----------> //

ll prime[N+10];
um  cou;

void PRIME() {
	for (ll i = 0; i <= N; i++) {
		prime[i] = i;
	}

	for (ll i = 4; i <= N; i += 2) {
		prime[i] = 2;
	}

	for (ll i = 3; i <= N; i += 2) {
		if (prime[i] == i) {
			for (ll j = i * i; j <= N; j += i) {
				if (prime[j] == j) prime[j] = i;
			}
		}
	}
}

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

unordered_map<ll , ll> factorize(ll x) {
	unordered_map<ll, ll> ans;

	while (x > 1) {
		ll m = prime[x];
		while (x % m == 0) {
			ans[m] = (ans[m] + 1) % MOD;
			x /= m;
		}
	}
	return ans;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;

	a = vll(n);
	for(ll i=0;i<n;i++) cin>>a[i];

	ll val = __gcd(a[0],a[1]);
	for(ll i=2;i<n;i++) {
		val = __gcd(val,a[i]);
	}

	if(val != 1) {
		cout<<"not coprime\n";
		return;
	}

	ll flag = 1;

	for(ll i=0;i<n;i++) {
		um b = factorize(a[i]);
		for(auto it : b) {
			cou[it.f] += it.s;
		}
	}

	for(ll i=0;i<n;i++) {
		um b = factorize(a[i]);
		for(auto it : b) {
			if(cou[it.f] != it.s) {
				flag = 0;
				break;
			}
		}
		if(flag == 0) break;
	}

	if(flag == 0) 	cout<<"setwise coprime\n";
	else 			cout<<"pairwise coprime\n";
}

int main() {
	fastio;randomINT;
	//cin>>T;
	PRIME();
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 264412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    string s;
    cin >> s;
    for (auto & c : s) {
        switch (c)
        {
        case '1':
            cout << '9';
            break;
        case '9':
            cout << '1';
            break;
        default:
            cout << c;
            break;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>

int main(){
  unsigned int a,b,tmp,GCD;
  while ( std::cin >> a >> b){
    if( b > a )std::swap( a , b );
    unsigned long int LCM = a;
    GCD = b;
    while(a % GCD != 0){
      tmp = a % GCD;
      a = GCD;
      GCD = tmp;
    }
    LCM = ( LCM / GCD ) * b;
    std::cout << GCD << " " << LCM << std::endl;
  }
  return 0;
}

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

using namespace std;
int main(void){
    // Your code here!
    string s, t;
    cin >> s >> t;
    
    int LCS[s.size()+1][t.size()+1];
    
    LCS[0][0] = 0;
    for(int i = 0; i < t.size(); i++){
        LCS[0][i+1] = 0;
    }
    for(int i = 0; i < s.size(); i++){
        LCS[i+1][0] = 0;
    }
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            if(s[i] == t[j]){
                LCS[i+1][j+1] = LCS[i][j] + 1;
            } else{
                LCS[i+1][j+1] = max(LCS[i+1][j], LCS[i][j+1]);
            }
        }
    } 
    
    int x = s.size();
    int y = t.size();
    string ans = "";
    
    while(x >= 1 && y >= 1){
        if(LCS[x][y] == LCS[x-1][y]) x--;
        else if(LCS[x][y] == LCS[x][y-1]) y--;
        else {
            x--;
            y--;
            ans.push_back(s[x]);
        }
    }
    
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A,B,C,D,L,R;
  cin >> A >> B >> C >> D;
	L=A+B;
    R=C+D;
	if(L > R){
      cout << "Left" << endl;
    }
	else if(L < R){
    cout << "Right" << endl;
   }
	else{
    cout << "Balanced" << endl;}
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define reps(i,a,b) for(long long int i=a;i<b;i++)
#define rep(i,a) for(long long int i=0;i<a;i++)
typedef long long int ll;
using namespace std;
ll MOD = 1000000007;

const int MAX = 510000;

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;



int main(){
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    string S;
    cin>>S;
    if(C<D){
        int yaba=0;
        for(int i=A-1;i<D-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                yaba++;
            }
        }
        if(yaba>0){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
    else{
        int yaba=0;
        for(int i=A-1;i<C-1;i++){
            if(S[i]=='#'&&S[i+1]=='#'){
                yaba++;
            }
        }
        if(yaba>0){
            cout<<"No"<<endl;
        }
        else{
            int daijo=0;
                for(int i=B-2;i<D-1;i++){
                    if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
                        daijo++;

                    }
                }
            if(daijo>0){
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
    }



    return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    string res;
    int dx = tx-sx, dy = ty-sy;
    rep(i, dx)res.push_back('R');
    rep(i, dy)res.push_back('U');
    rep(i, dx)res.push_back('L');
    rep(i, dy)res.push_back('D');
    res.push_back('D'); 
    rep(i, dx+1)res.push_back('R');
    rep(i, dy+1)res.push_back('U');
    res.push_back('L');
    res.push_back('U');
    rep(i, dx+1)res.push_back('L');
    rep(i, dy+1)res.push_back('D');
    res.push_back('R');
    cout << res << ln;
}


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

/*-------------------Define Start-------------------*/
typedef bool BL;                        // 布尔类型
typedef char SB;                        // 有符号1字节,8位
typedef unsigned char UB;                // 无符号1字节,8位
typedef short SW;                        // 有符号短整型,16位
typedef unsigned short UW;                // 无符号短整型,16位
typedef long SDW;                        // 有符号整型,32位
typedef unsigned long UDW;               // 无符号整型,32位
typedef long long SLL;                    // 有符号长整型,64位
typedef unsigned long long ULL;            // 无符号长整型,64位
typedef char CH;                        // 单个字符
typedef float R32;                        // 单精度浮点数
typedef double R64;                        // 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define ALL(x) x.begin(),x.end()

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;                //常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;                //用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;    //用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 2e5 + 7;
SLL N, K;
SLL ans;

SLL fac[maxN];
void init_fact() {
    fac[0] = 1;
    For(i, 1, maxN - 1) {
        fac[i] = (i * fac[i - 1]) % mod;
    }
}

void input(){
    cin >> N >> K;
    init_fact();
}

// Calculate x^y % p
inline SLL pow_mod(SLL x, SLL y, ULL p = mod){
	SLL ret = 1;
	while(y){
		if(y & 1) {
			ret = (ret * x) % p;
		}
        x = (x * x) % p;
        y >>= 1;
	}
	return ret;
} 

//ax + by = gcd(a, b) = d
// 扩展欧几里德算法
/**
 *    a*x + b*y = 1
 *    如果ab互质，有解
 *    x就是a关于b的逆元
 *    y就是b关于a的逆元
 *     
 *    证明： 
 *        a*x % b + b*y % b = 1 % b
 *        a*x % b = 1 % b
 *        a*x = 1 (mod b)
 */
inline void ex_gcd(SLL a, SLL b, SLL &x, SLL &y, SLL &d){
    if(!b) {
        d = a, x = 1, y = 0;
    }
    else{
        ex_gcd(b, a % b, y, x, d);
        y -= x * (a / b);
    }
}

// 求a关于p的逆元，如果不存在，返回-1 
// a与p互质，逆元才存在 
inline SLL inv_mod(SLL a, SLL p = mod){
    SLL d, x, y;
    ex_gcd(a, p, x, y, d);
    return d == 1 ? (x % p + p) % p : -1;
}

inline SLL comb_mod(SLL m, SLL n) {
    SLL ret;

    if(m > n) {
        swap(m, n);
    } 
    
    ret = (fac[n] * inv_mod(fac[m], mod)) % mod;
    ret = (ret * inv_mod(fac[n - m], mod)) % mod;
    
    return ret;
}

void solve(){
    For(i, 0, min(K, N - 1)) {
    	ans = (ans + comb_mod(i, N) * comb_mod(i, N - 1)) % mod;
	}
}

void output(){
    cout << ans << endl;
}

int main() {
    input();
    solve();
    output();
    return 0;
}

Measured memory_bytes: 1792
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;

long long Pow[(long long)4e5+100];
long long GetPow(long long l) {
   if(!Pow[l]) Pow[l] = (GetPow(l-1)*2)%MOD;
   return Pow[l];
}


int main(void) {
    ll N;
    cin>>N;
    vector<ll> C(N);
    rep(i,0,N) cin>>C[i];
    sort(C.begin(),C.end());

    ll ans = 0;
    Pow[0] = 1;
    ll num = GetPow(2*N-2);
    rep(i,0,N) {
        ans += ((((C[N-i-1]%MOD) * num)%MOD) * (2+i))%MOD;
        ans %= MOD;
    }
    ans = (ans+MOD)%MOD;
    cout<<ans<<endl;









   return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;

#define REP(i, x) for(int i=0;i<(int)(x);i++)
#define REPS(i, x) for(int i=1;i<=(int)(x);i++)
#define RREP(i, x) for(int i=(int)(x)-1;i>=0;i--)
#define RREPS(i, x) for(int i=(int)(x);i>0;i--)
#define FOR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;

int n, p[300000];

int solve(string s){
        vector<char> st(1, '#');
        FOR(q, s){
                char c = *q;
                if(c == '(' || c == '[') st.pb(c);
                if(c == ')'){
                        if(st.back() != '(') return 0;
                        st.pop_back();
                }
                if(c == ']'){
                        if(st.back() != '[') return 0;
                        st.pop_back();
                }
        }       
        return st.size() == 1;
}

int main(){
        string s;
        while(getline(cin, s), s != "."){
                cout << (solve(s) ? "yes" : "no") << endl;
        }
        return 0;
}

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

int main() {
  cin >> N;
  A.resize(N);
  B.resize(N);
  rep(i,0,N - 1) cin >> A[i] >> B[i];
  vector<pair<i64,i64>> vec;
  rep(i,0,N - 1) vec.push_back({A[i] + B[i],i});
  sort(all(vec));
  i64 ans = 0;
  for(int i = N - 1;i >= 0;i--) {
    ans += A[vec[i].second];
    i--;
    if(i >= 0) {
      ans -= B[vec[i].second];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3956
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	
	void solve() {
		int N = sc.nextInt();
		int[] count = new int[26];
		for (int i = 0; i < count.length; i++) count[i] = 1000000;
		for (int i = 0; i < N; i++) {
			int[] s = new int[26];
			for (char c : sc.next().toCharArray()) {
				++s[c - 'a'];
			}
			for (int j = 0; j < count.length; j++) 
				count[j] = min(count[j], s[j]);
		}
		String ans = "";
		for (int j = 0; j < count.length; j++) {
			for (int i = 0; i < count[j]; i++) {
				ans = ans + (char)('a' + j);
			}
		}
		out.println(ans);
		
	}
	
	static void tr(Object... os) { System.err.println(deepToString(os)); }
	static void tr(int[][] as) { for (int[] a : as) tr(a); }

	void print(int[] a) {
		out.print(a[0]);
		for (int i = 1; i < a.length; i++) out.print(" " + a[i]);
		out.println();
	}

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

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(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;
		}
	}
}

Measured memory_bytes: 21460
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(void){
    ll n; cin >> n;
    ll a[n];
    for(ll i=1; i<=n; i++){
        cin >> a[i];
    }

    ll b[n+1]={0};
    // 後ろから見ていく
    // 後ろ半分はaと一致
    
    for(ll i=n; i>=1; i--){
        ll sum_i = 0;
        for(ll j=i; j<=n; j+=i){
            sum_i += b[j];
        }
        if(sum_i%2 == a[i]) b[i]=0;
        else b[i]=1;
    }

    // M=counter(出力用)
    ll counter=0;
    for(ll i=1; i<=n; i++){
        if(b[i] == 1) counter++;
    }

    // 出力(-1になる事ないよ、これ)
    cout << counter << "\n";
    for(ll i=1; i<=n; i++){
        if(b[i] == 1) cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
using namespace std;
int main(void){
    
    int N[6];
    for(int i = 1; i < 6; i++){
        cin >> N[i];
    }
    
    for(int i = 1; i < 6; i++){
        if(N[i] == 0){
            cout << i << endl;
            break;
        }
    }
    
    
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 900000000000000
int h,w;
char G[405][405];
bool J[405][405];
vector<int>dh(4),dw(4);
int bfs(int x,int y){
    int cw=0,cb=0;
    if(G[x][y]=='.')cw++;
    else cb++;
    queue<P>Q;
    Q.push(make_pair(x,y));
    J[x][y]=true;
    while(!Q.empty()){
        int x0=Q.front().F,y0=Q.front().S;Q.pop();
        rep(i,4){
            int tx=x0+dh[i],ty=y0+dw[i];
            if(tx<0||tx>=h||ty<0||ty>=w)continue;
            if(J[tx][ty])continue;
            if(G[tx][ty]!=G[x0][y0]){
                J[tx][ty]=true;
                Q.push(make_pair(tx,ty));
                if(G[tx][ty]=='.')cw++;
                else cb++;
            }
        }
    }
    return cw*cb;
    
}
signed main(){
    cin>>h>>w;
    dh={0,1,0,-1};
    dw={1,0,-1,0};
    rep(i,h)cin>>G[i];
    memset(J,0,sizeof(J));
    int ans=0;
    rep(i,h)rep(j,w){
        if(!J[i][j]){
            ans+=bfs(i,j);
        }
    }
    cout<<ans<<endl;
    
    
}
        

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1e+7
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int dp[2019];
signed main() {
    garou;
    string s;
    cin>>s;
    int n=s.length();
    dp[0]=1;
    int c=1;
    int l=0;
    for(int i=n-1;i>=0;i--){
    l+=((s[i]-'0')*c);
    l%=2019;
    c=(c*10)%2019;
   dp[l]++;
    }
    int ans=0;
    for(int i=0;i<2019;i++){
        ans+=(dp[i]*(dp[i]-1))/2;
    }
    cout<<ans;
}

Measured memory_bytes: 3756
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

void debug(vec &v) {
	int n = v.size();
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

int trans(char t) {
	if (t == 'r') {
		return 2;
	}
	else if (t == 's')return 0;
	else return 1;
}
ll a[1 << 17];
int n; ll m;
ll calc(int x) {
	ll num = 0;

	rep(i, n) {
		int le = a[i];
		int id = lower_bound(a, a + n, x-le) - a;
		num += (n - id);
	}
	return num;
}

void solve() {
	cin >> n >> m;
	
	rep(i, n) {
		cin >> a[i];
	}
	sort(a,a+n);
	int le = 0, ri = 1 << 18;
	while (ri - le > 1) {
		int mid = (le + ri) / 2;
		ll s = calc(mid);
		if (s >= m)le = mid;
		else ri = mid;
	}
	vector<ll> ra(n + 1);
	rep(i, n)ra[i+1] = ra[i] + a[i];
	ll ans = 0;
	rep(i, n) {
		int id = upper_bound(a, a + n, le-a[i]) - a;
		ll cnt = n - id;
		ans += cnt * a[i] + (ra[n] - ra[id]);
		m -= cnt;
	}
	//cout << m << endl;
	ans += m * le;
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define int int64_t
#define div div__
#define rep(i, a, b) for(int i = a; i < b; ++i)

int debug = 0;

const int N = 2e5 + 10;
int mod = 1e9 + 7;

int n, k, cp[N], isp[N], pw_[N];
vector <int> primes;

int add(int a, int b) {
    a += b;
    while (a >= mod) a -= mod;
    return a;
}

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

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

int pw(int x, int p) {
    if (p == 0) return 1;
    if (p&1) return pw(x, p - 1) * x % mod;
    int pp = pw(x, p / 2);
    return pp * pp % mod;
}

int rev(int a) {
    return pw(a, mod - 2);
}

int div(int a, int b) {
    return mul(a, rev(b));
}

void precalc() {
    memset(isp, 1, sizeof(isp));
    rep(i, 2, k + 1) {
        if (isp[i]) {
            primes.push_back(i);
            for (int j = i * i; j <= k + 1; j += i) {
                isp[j] = 0;
            }
        }
    }
    cp[0] = cp[1] = -1;
    rep(i, 2, k + 1) {
        if (isp[i]) {
            cp[i] = 1;
            continue;
        }
        int flag = 1;
        int x = i, cnt = 0;
        for (int d : primes) {
            if (x == 1) break;
            if (x % d == 0) {
                cnt++;
                if (x % (d * d) == 0) {
                    flag = 0;
                    break;
                }
                while (x % d == 0) {
                    x /= d;
                }
            }
        }
        if (flag) {
            cp[i] = cnt;
        } else {
            cp[i] = -1;
        }
    }
    if (debug) {
        cerr << " cp = ";
        rep(i, 1, 11) {
                cerr << cp[i] << ' ';
            }
            cerr << '\n';
    }
    rep(x, 0, k + 1) {
        pw_[x] = pw(x, n);
    }
}

int f(int kk) {
    int res = pw(kk, n);
    rep(x, 2, kk + 1) {
        if (cp[x] != -1) {
            if (cp[x] % 2) {
                res = sub(res, pw_[kk / x]);
            } else {
                res = add(res, pw_[kk / x]);
            }
        }
    }
    return res;
}

main() {
    cin >> n >> k;
    int ans = 0;
    precalc();
    rep(g, 1, k + 1) {
        ans = add(ans, mul(f(k / g), g));
        if (debug) {
            /// cerr << " n/g: " << n/g << " f: " << f(n/g) << '\n';
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 6952
import math
n = int(input())
a = int(n/1.08)
if math.floor((a+1)*1.08) == n:
  print(a+1)
elif math.floor((a-1)*1.08) == n:
  print(a-1)
elif math.floor(a*1.08) == n:
  print(a)
else:
  print(':(')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
void solve(int p, int q){
    vector<string> v(p), u(q);
    for (auto &&i : v) cin >> i;
    for (auto &&i : u) cin >> i;
    vector<int> ans(q, -2);
    for (int R = 1; R <= 20; ++R) {
        for (int C = 1; C <= 20; ++C) {
            for (int S = 1; S <= 20; ++S) {
                int cnt1 = 0, cnt2 = 0, cnt3 = 0;
                int ok = 1;
                for (int i = 0; i < p; ++i) {
                    int x = 0;
                    for (auto &&j : v[i]) {
                        if(j == '.') x++;
                        else break;
                    }
                    if(x != R*cnt1+C*cnt2+S*cnt3){
                        ok = 0;
                        break;
                    }
                    for (auto &&j : v[i]) {
                        if(j == '(') cnt1++;
                        if(j == ')') cnt1--;
                        if(j == '{') cnt2++;
                        if(j == '}') cnt2--;
                        if(j == '[') cnt3++;
                        if(j == ']') cnt3--;
                    }
                }
                if(!ok) continue;
                for (int i = 0; i < q; ++i) {
                    if(ans[i] == -2){
                        ans[i] = R*cnt1+C*cnt2+S*cnt3;
                    } else if(ans[i] != R*cnt1+C*cnt2+S*cnt3){
                        ans[i] = -1;
                    }
                    for (auto &&j : u[i]) {
                        if(j == '(') cnt1++;
                        if(j == ')') cnt1--;
                        if(j == '{') cnt2++;
                        if(j == '}') cnt2--;
                        if(j == '[') cnt3++;
                        if(j == ']') cnt3--;
                    }
                }
            }
        }
    }
    for (int i = 0; i < q; ++i) {
        if(i) printf(" ");
        printf("%d", ans[i]);
    }
    puts("");
}
int main() {
    int p, q;
    while(cin >> p >> q, p){
        solve(p, q);
    }
    return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    if((n-1)%(k-1)==0)cout<<(n-1)/(k-1)<<endl;
    else cout<<(n-1)/(k-1)+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> v(n);
  rep(i, n) cin >> v[i];

  vector<mint> cur(s), next(s);
  rep(i, s) cur[i] = 0;
  rep(i, n) {
    rep(j, s) {
      next[j] = mint(2) * cur[j] + (j + 1 == v[i] ? mint(2).pow(i) : 0)
              + (j + 1 > v[i] ? cur[j-v[i]] : 0);
    }
    rep(j, s) cur[j] = next[j];
  }

  cout << next[s-1].x << endl;
  return 0;
}

/*
*/


Measured memory_bytes: 3664
#include <stdio.h>

#define MAX 100

int n, a[MAX], cnt;

void selectionSort()
{
	int i, j, tmp, minj;
	cnt = 0;
	
	for (i = 0; i <= n-1; i++) {
		minj = i;
		
		for (j = i; j <= n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
				
			}
		}
		
		tmp = a[i];
		a[i] = a[minj];
		a[minj] = tmp;
		
		if (i != minj) {
			cnt++;
		}
	}
	
}

int main()
{
	int i;
	
	scanf("%d\n",&n);
	
	for (i = 0; i < n; i++) {
		 scanf ("%d",&a[i]);
	}
	
	selectionSort();
	
	for (i = 0; i < n; i++) {
		if (i > 0) {
			printf(" ");
			}
		printf("%d",a[i]);
	}
	printf("\n");
	
	printf("%d\n",cnt);
return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

struct Info{ll v; ll c; ll t;};
struct DP{
	ll v; ll c; ll t;
	bool operator<(const DP& o) const{
		return t > o.t;
	}
};

int mainsolve(){

	ll n,m,s;
	cin >> n >> m >> s;
	vector<ll> a(m), b(m);
	vector<vector<Info>> to(n);
	rep(i,m){
		ll u,v;
		cin >> u >> v >> a[i] >> b[i];
		--u; --v;
		to[u].push_back(Info{v,a[i],b[i]});
		to[v].push_back(Info{u,a[i],b[i]});
	}
	vector<ll> c(n), d(n);
	rep(i,n) cin >> c[i] >> d[i];

	ll INF = 1e18;
	ll maxc = n*50; // 銀貨の枚数はこれだけあれば十分
	vector<vector<ll>> dp(n,vector<ll>(maxc,INF)); // dp[v][c]: 銀貨c枚持ってvにいる状態にするためにかかる時間 

	priority_queue<DP> q;
	q.push(DP{0,min(maxc-1,s),0});

	while(!q.empty()){
		DP now = q.top(); q.pop();
		if(now.c >= 0 && now.t >= 0 && now.t < dp[now.v][min(maxc-1,now.c)] ){
			dp[now.v][min(maxc-1,now.c)] = now.t;
q.emplace(DP{now.v,now.c + c[now.v], now.t + d[now.v]}); // 換金
			for(Info next : to[now.v]){
				q.emplace(DP{next.v,now.c - next.c, now.t + next.t}); // 移動
			}
			
		}
	}
	
	rep(i,n){
		if(i==0) continue;
		ll res = INF;
		rep(j,maxc) res = min(res, dp[i][j]);
		cout << res << endl;
	}
	
	return 0;
}

int main(){

	return mainsolve();
}


Measured memory_bytes: 16336
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

bool ispair(const string& a,const string& b)
{
	return a=='~'+b || '~'+a==b;
}

int main()
{
	for(string s;getline(cin,s),s!="#";){
		replace(allof(s),'(',' ');
		replace(allof(s),')',' ');
		replace(allof(s),'|',' ');
		replace(allof(s),'&',' ');
		
		istringstream iss(s);
		bool res=false;
		for(string ts[3];iss>>ts[0]>>ts[1]>>ts[2];){
			bool haspair=false;
			rep(i,3) repi(j,i+1,3)
				haspair|=ispair(ts[i],ts[j]);
			res|=!haspair;
		}
		
		cout<<(res?"yes":"no")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    int R;
    cin>>R;

    
    if (R<1200) {
        cout<<"ABC"<<endl;
    }else 
    if (R>=1200&&R<2800) {
        cout<<"ARC"<<endl;
    }
    else
    {
        cout<<"AGC"<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
A=input()
B=input()
C=input()
x=A[0]
while (len(A)!=0)or(len(B)!=0)or (len(C)!=0):
    if x =="a":
        if A=="":
            print("A") 
            exit()       
        x=A[0]
        A=A[1:]
 
    elif x=="b":
        if B=="":
            print("B")
            exit()
        x=B[0]
        B=B[1:]

    elif x=="c":
        if C=="":
            print("C") 
            exit()
        x=C[0]
        C=C[1:]

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

  int w0,r0,c,r,i;

  while(1){
    scanf("%d%d%d%d",&r0,&w0,&c,&r);
    if(r0==0 && w0==0 && c==0 && r==0)break;

    //    printf("%d %d %d %d\n",r0,w0,c,r);                                                                   
    //  printf("%f\n",(double)r0/w0);                                                                          
    if(c*w0 <= r0){
      printf("0\n");
    }else{
      //  printf("1\n");                                                                                       
      for(i=1;;i++){
        //printf("%d\n",i);                                                                                    
        if( r0 + r*i >= c*w0 ){
          printf("%d\n",i);
          break;
        }

      }
    }


  }


  return 0;

}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  int score_Alice = 0;
  int score_Bob = 0;
  
  for (int i = 0 ; i < N ; i++){
    if ( i % 2 == 0){
      score_Alice = score_Alice + A.at(i);
    }
    else { score_Bob = score_Bob + A.at(i);
         }
  }
  cout << score_Alice - score_Bob<< endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)
const double EPS = 1e-9;


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

    int A, B, C; cin >> A >> B >> C;
    cout << (A+B >= C ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 256