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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int main() {
	int n;
	scanf("%d", &n);
	char s[104];
	int sum = 0;
	map<string, int> cnt;
	for(int i = 0; i < n; i++){
		int t;
		scanf("%s %d", s, &t);
		sum += t;
		cnt[s] = sum;
	}
	scanf("%s", s);
	printf("%d\n", sum - cnt[s]);
	return 0;
}


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

int main()
{
  int sum, A, B;
  cin >> A >> B;
  
  sum = 0;
  while (A <= B)
  {
    if (A % 10 == A / 10000 &&
        (A / 10) % 10 == (A / 1000) % 10)
      sum++;
    A++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
// -- telegram @rentixous --
// -- keep calm and slava ukraini --
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5+1488;
bool ban[N];
signed main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll x, n;
    cin >> x >> n;
    for(ll a, i = 0;i<n;i++){
        cin >> a;
        ban[a]=1;
    }
    ll mdst = LLONG_MAX, mv=0;
    for(ll i =max(0ll, x-200);i<=x+200;i++){
        if(ban[i]) continue;
        ll dd = abs(x-i);
        if(dd<mdst){
            mdst=dd, mv=i;
        }
    }
    cout<<mv;
}

Measured memory_bytes: 3632
#include "stdio.h"
#include "math.h"

int main(){
	int a;
	scanf("%d", &a);
	int max=1;
	int i;
	for (i=2;i<=31;i++){
		if(i*i>a)break;
	
		int j=i*i;
	
		while(j*i<=a){
			j*=i;
		}
		if(max<j)max=j;
		
	}
	printf("%d",max);
	
return 0;

}





Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int coordinate1, total = 0;
  int coordinate2, num_ball, pos_ball;
  
  cin >> num_ball >> coordinate2;
  for (int i = 0; i < num_ball; i++) {
    cin >> pos_ball;
    if (pos_ball < coordinate2 - pos_ball) {
      total += pos_ball * 2;
    }
    else {
      total += (coordinate2 - pos_ball) * 2;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      string s;
      cin>>s;
      if(s=="RRR") cout<<3;
      else if(s=="RRS"||s=="SRR") cout<<2;
      else if(s=="SSS") cout<<0;
      else cout<<1;
}

Measured memory_bytes: 3624
N=int(input())
Index=[0]*(N+1)
ans=1
Divider=pow(10,9)+7
for i in range(N+1):
    for j in range(i+1):
        if j>1:
            while i%j==0:
                i=int(i/j)
                Index[j]+=1
#print(Index)
for i in range(N+1):
    ans=ans*(Index[i]+1)%Divider
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  random_device rd;
  mt19937 mt(rd());
  uniform_int_distribution<ll> a(1,26);
  vector<ll> day(26);
  vector<pair<ll,ll>> c(26);
  ll d;
  cin >> d;
  rep(i,26) {
    ll t;
    cin >> t;
    c[i] = pair(t,i);
  }
  Sort(c);
  ll p = 0;
  rep(i,26) {
    if (c[i].first < 65) {
      p = i;
      break;
    }
  }
  ll cnt = 0;
  while (1) {
    rep(i,p) {
      cout << c[i].second +1 << '\n';
      ++cnt;
      if (cnt >= 365) {
        return 0;
      }
    }
    rep(i,(26-p)/2) {
      cout << c[i+p].second +1 << '\n';
      ++cnt;
      if (cnt >= 365) {
        return 0;
      }
    }
    rep(i,p) {
      cout << c[i].second +1 << '\n';
      ++cnt;
      if (cnt >= 365) {
        return 0;
      }
    }
    rep(i,((26-p)+1)/2) {
      cout << c[i+p+(26-p)/2].second +1 << '\n';
      ++cnt;
      if (cnt >= 365) {
        return 0;
      }
    }
  }  
}

Measured memory_bytes: 3652
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, K;
int P[200000];

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> P[i];

    set<int> st;
    rep(i, K) st.insert(P[i]);

    int ans = 1;
    rep(i, N-K){
        if(P[i] != *st.begin() || P[i+K] < *prev(st.end())){
            ans++;
        }
        st.erase(P[i]);
        st.insert(P[i+K]);
    }

    int tmp = 1;
    int cnt = 0;
    for(int i=1; i<N; i++){
        if(P[i-1] < P[i]) tmp++;
        else{
            if(tmp >= K) cnt++;
            tmp = 1;
        }
    }
    if(tmp >= K) cnt++;
    if(cnt > 0) ans -= cnt-1;

    cout << ans << endl;
}

Measured memory_bytes: 13772
#include <cmath>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <fstream>
using namespace std;

#define maxn 100010
#define inf 1000000000000000000LL
#define ll long long

int main() {
    // freopen("test.in", "r", stdin);
    string s;
    cin >> s;

    bool ok1 = false, ok2 = false;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'C') {
            ok1 = true;
        }
        if (ok1 == true && s[i] == 'F') {
            ok2 = true;
        }
    }
    if (ok2) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int t = sc.nextInt();
      int[] a = new int[t];
      int sum = 0;
      int max = 0;
      for(int i = 0;i < t;i++){
        a[i]=sc.nextInt();
        sum+=a[i];
        max = Math.max(max,a[i]);
      }
      sum -=max;
      if(max-1<=sum)System.out.println(0);
      else System.out.println(max-1-sum);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  unsigned long long int N;
  string d;
  cin >> N >> d;
  cout <<(N*int(d.at(0)-'0')*100+N*int(d.at(2)-'0')*10+N*int(d.at(3)-'0'))/100 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> dp(3);
    cin >> dp[0] >> dp[1] >> dp[2];
    for (int i = 1; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        int a1 = dp[0], b1 = dp[1], c1 = dp[2];
        dp[0] = max(a + b1, a + c1);
        dp[1] = max(b + a1, b + c1);
        dp[2] = max(c + a1, c + b1);
    }
    cout << max(max(dp[0], dp[1]), dp[2]);
}


Measured memory_bytes: 256
n,a,b,c,d = gets.split.map(&:to_i)
s = " " + gets.chomp

if c < d
    puts s[a..c] =~ /##/ || s[b..d] =~ /##/ ? "No" : "Yes"
else
    puts s[a..c] =~ /##/ || !(s[b-1..d+1] =~ /\.\.\./) ? "No" : "Yes"
end

Measured memory_bytes: 2556
#include<bits/stdc++.h>
#pragma GCC diagnostic error "-std=c++14"
using namespace std;

const int maxn=2e5+9;
vector < int > neib[maxn];
int val[maxn];
int n,q;


int prepare(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<n;++i){
        int a,b;scanf("%d%d",&a,&b);
        neib[a].push_back(b);
        neib[b].push_back(a);
    }
}

int operate(){
    for(int i=0;i<q;++i){
        int p,x;scanf("%d%d",&p,&x);
        val[p]+=x;
    }
}

int solvetree(int r,int fa){
    for(int x : neib[r]){
        if(x==fa) continue;
        val[x]+=val[r];
        solvetree(x,r);
    }
}

int solve(){
    solvetree(1,-1);
    for(int x=1;x<n;++x)
        printf("%d ",val[x]);
    printf("%d\n",val[n]);
}
int main(){
    prepare();
    operate();
    solve();
    return 0;
}

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

int main()
{
    string s;
    int k;
    cin>>k;
    cin>>s;
    if(s.length() <= k)
    {
        cout<<s;
    }
    else if(s.length() > k)
    {
        for(int i = 0; i < k; i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}


int main(){
    int k,x;cin >> k >> x;
    cout << ((500*k>=x)?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 998244353;//1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    int n;
    cin>>n;
    Yn(n>=30);
}



Measured memory_bytes: 3620
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

double p[301][301][301], ev[301][301][301];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vi start(4);
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        start[a]++;
    }
    p[start[1]][start[2]][start[3]] = 1;
    for (int c = n; c >= 0; c--) {
        for (int b = n; b >= 0; b--) {
            for (int a = n; a >= 0; a--) {
                if (a + b + c == 0 || a + b + c > n) continue;
                double p_waste = (double) (n - (a + b + c)) / n;
                double ev_wasted = p_waste / (1 - p_waste) + 1;
                ev[a][b][c] += ev_wasted * p[a][b][c];
                if (a) {
                    double p_a = (double) a / (a + b + c);
                    p[a - 1][b][c] += p[a][b][c] * p_a;
                    ev[a - 1][b][c] += ev[a][b][c] * p_a;
                }
                if (b) {
                    double p_b = (double) b / (a + b + c);
                    p[a + 1][b - 1][c] += p[a][b][c] * p_b;
                    ev[a + 1][b - 1][c] += ev[a][b][c] * p_b;
                }
                if (c) {
                    double p_c = (double) c / (a + b + c);
                    p[a][b + 1][c - 1] += p[a][b][c] * p_c;
                    ev[a][b + 1][c - 1] += ev[a][b][c] * p_c;
                }
            }
        }
    }
    cout << fixed << setprecision(10) << ev[0][0][0] << endl;

    return 0;
}

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

using namespace std;

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

    int rc;

    if (N == 1) {
        rc = 1;
    } else if (N == 2 || N < 4) {
        rc = 2;
    } else if (N == 4 || N < 8) {
        rc = 4;
    } else if (N == 8 || N < 16) {
        rc = 8;
    } else if (N == 16 || N < 32) {
        rc = 16;
    } else if (N == 32 || N < 64) {
        rc = 32;
    } else if (N == 64 || N < 128) {
        rc = 64;
    } else {
        rc = 128;
    }

    cout << rc << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int max(int a,int b){return a>b?a:b;}
int main() {
	int p = -1, l = 0, m = 0;
	char b[11];
	scanf("%s", b);
	while(b[++p]) {
		if(b[p] == 'A' || b[p] == 'C' || b[p] == 'G' || b[p] == 'T')
			l++;
		else {
			m = max(m, l);
			l = 0;
		}
	}
	printf("%d", max(m, l));
	return 0;
}

Measured memory_bytes: 128
K = int(input())
A,B = map(int,input().split())

a = A//K
b = B//K

flag = 0

for i in range(a,b+1):
    N = K*i
    if A<= N <= B:
        flag = 1
        print("OK")
        break

if flag == 0:
    print("NG")

Measured memory_bytes: 9068
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

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

        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }

        sc.close();

        list.sort(Comparator.reverseOrder());

        int sum = 0;

        for (int i = 0; i < k; i++) {
            sum += list.get(i);
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 21972
#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 sortu(x) sort((x).begin(),(x).end())
#define sortd(x) sort((x).begin(),(x).end(), greater<int>())
#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 snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cerr<<#x<<" = "<<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 getInt(){int x;scanf("%d",&x);return x;}
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.fi<<","<<v.se;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const v(T)&a){ll res(0);for(auto&&x:a)res+=x;return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1e9+7;
#define dame0 { puts("0"); return 0;}
#define dame1 { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define yn2 {puts("YES");}else{puts("NO");}
#define yn3 {puts("yes");}else{puts("no");}
#define on {puts("ok");}else{puts("ng");}
#define on2 {puts("OK");}else{puts("NG");}
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define outa {cout << ans << endl;}
#define out(x) {cout << x << endl;}
using Graph = vector<vector<int>>;
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//mins(ans,now);  ansに最小値が入る
//if(max(ans,now)) ansが小さければ更新して実行
//ll sum = suma(a);
//int a[33][4];


int main(){
  int s; cin>>s;
  vector<int>dp(s+1,0);
  dp[0] = 1;
  rep(i,s+1){
    rep(j, i-3+1){
      dp[i] = dp[i] + dp[j];
      dp[i] = dp[i] % MOD;
    }
  }
  cout << dp[s] << endl;
}

 /*
g++ a.cpp
./a.out

oj d
oj t

debug:ctrl+shift+B problemin

*/


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

void solve(){
  int n, T; cin >> n >> T;
  vector<int> c(n), t(n);
  int minc = 1001;
  for(int i = 0; i < n; i++){
    cin >> c[i] >> t[i];
    if(t[i] <= T) minc = min(c[i], minc);
  }
  if(minc == 1001) cout << "TLE\n";
  else cout << minc << endl;
  return;
}

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


Measured memory_bytes: 256
// ABC091 D

#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

using ll = long long;
#define int ll

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];

    int ret = 0;

    for (int k = 0; k <= 29; ++k) {
        int T = 1;
        for (int j = 0; j < k; j++) T *= 2;

        vector<int> C(N);
        vector<int> D(N);
        for (int i = 0; i < N; i++) {
            C[i] = A[i] % (2 * T);
            D[i] = B[i] % (2 * T);
        }
        sort(D.begin(), D.end());

        int cnt = 0;
        for (int c : C) {
            cnt += lower_bound(D.begin(), D.end(), 2*T-c) - lower_bound(D.begin(), D.end(), T-c);
            cnt += lower_bound(D.begin(), D.end(), 4*T-c) - lower_bound(D.begin(), D.end(), 3*T-c);
        }

        if (cnt % 2 == 1) ret += T;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 8480
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 998244353

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, S = LI()
    a = LI()
    dp = [[0 for _ in range(S+1)] for _ in range(N+1)]
    for i in range(1, N+1):
        dp[i][0] = dp[i-1][0] * 2 + 1
        dp[i][0] %= mod
    for i in range(N):
        for j in range(1, S+1):
            if j - a[i] >= 0:
                dp[i+1][j] = (dp[i][j-a[i]] % mod) + (dp[i][j] * 2 % mod)
            else:
                dp[i+1][j] = dp[i][j] * 2 % mod
            if j == a[i]:
                dp[i+1][j] += 1
            dp[i+1][j] %= mod
    print(dp[N][S])

main()



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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

struct GN {
  int m, n;

  GN(int m, int n) {
    this->n = n;
    this->m = m;
  }

  GN mult(GN gn2) {
    int x = gn2.m, y = gn2.n;
    return GN(m*x - n*y, m*y - n*x);
  }

  bool isdivof(GN gn1){
    int p = gn1.m, q = gn1.n;
    int tmp = m * m + n * n;
    if(tmp == 0) return false;
    return ((m*p + n*q) % tmp == 0) && ((m*q - n*p) % tmp == 0);
  }

  bool isprimedivof(GN gn1) {
    int x = gn1.m, y = gn1.n;
    return ((m == 1 && n == 0) || (m == 0 && n == 1) ||
            (m == -1 && n == 0) || (m == 0 && n == -1) ||
            (m == x && n == y) || (m == -y && n == x) ||
            (m == -x && n == -y) || (m == y && n == -x));
  }
};

GN operator*(GN gn1, GN gn2) {
  return gn1.mult(gn2);
}


int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int q; cin >> q;
  while(q > 0) {
    int m, n; cin >> m >> n;
    GN gn1 = GN(m, n);
    int tmp = m * m + n * n;
    if(tmp <= 1) {
      cout << "C" << endl;
    } else {
      bool prime = true;
      for(int i=0;i*i<=tmp;++i) {
        for(int j=0;i*i+j*j<=tmp;++j) {
          // cout << i << ":" << j << endl;
          GN gn2 = GN(i, j);
          if(gn2.isdivof(gn1) && !gn2.isprimedivof(gn1)) {
            prime = false;
          }
        }
      }
      cout << (prime ? "P" : "C") << endl;
    }

    --q;
  }
}



Measured memory_bytes: 3044
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	map<int, int> input;
	long sum = 0;
	for (int i = 0; i < N; i++) {
		int A;
		scanf("%d", &A);
		input[A]++;
		sum += A;
	}
	int Q;
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		int B, C;
		scanf("%d %d", &B, &C);
		// cout << input[B] << "\n";
		sum += (C - B) * input[B];
		input[C] += input[B];
		input[B] = 0;
		printf("%ld\n", sum);
	}
	return 0;
}


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

int main(){
    int N, v, j;
    cin >> N;
    vector<int> list(N);
    for (int i=0; i<N; i++){
        cin >> list.at(i);
        if (i==N-1){
            cout << list.at(i) << endl;
        }else{
            cout << list.at(i) << ' ';
        }
    }
    for (int i=1; i<N; i++){
        v = list[i];
        j = i - 1;
        while (j >= 0 && list[j] > v){
            list[j+1] = list[j];
            j--;
        }
        list[j+1] = v;
        for (int i=0; i<N; i++){
            if (i==N-1){
                cout << list.at(i) << endl;
            }else{
                cout << list.at(i) << ' ';
            }     
        }
    }
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 400+1;
const ll oo = numeric_limits<ll>::max();
ii memo[maxn][maxn];
int N,A[maxn];

ii dp(int i,int j){
	if(i == j){
		return ii(0,A[j]);
	}else if(i+1 >= j){
		return ii(A[i]+A[j],A[i]+A[j]);
	}
	ii &res = memo[i][j];
	if(res != ii(-1,-1))return res;
	res = ii(oo,oo);
	for(int k = i; k < j; k++){
		ii p1 = dp(i,k);
		ii p2 = dp(k+1,j);
		ii act = ii(p1.se+p2.se+p1.fi+p2.fi,p1.se+p2.se);
		res = min(res,act);
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	forn(i,0,N)forn(j,0,N)memo[i][j] = ii(-1,-1);
	forn(i,0,N)cin >> A[i];
	ii res = dp(0,N-1);
	cout << res.fi << '\n';
	
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 2816
N=int(input())
B=list(map(int,input().split(' ')))
ans = []
for i in range(N):
    for n,j in enumerate(B[::-1]):
        if N-i-n==j:
            ans.append(B.pop(N-i-n-1))
            break
if len(ans)==N:
    for i in ans[::-1]:
        print(i)
else:
    print(-1)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;
char s1[100005], s2[100005];
int a[110], b[110];


int main()
{
	int n, a, b;
	while(~scanf("%d %d %d", &n, &a, &b))
	{
		if(a+1 == b)
		{
			int maxx = -1;
			int c = a - 1;
			int d = n - b;
			int e = b - 2;
			if(d > e)
				maxx = d;
			else
				maxx = e;
			if(c == maxx)
				printf("Borys\n");
			else if(c < maxx)
				printf("Borys\n");
			else
				printf("Alice\n");
		}
		else
		{
			if((b - a) % 2 == 0)
				printf("Alice\n");
			else
				printf("Borys\n");
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

long long dif(const vector<long long>& s)
{
	return *max_element(s.begin(), s.end()) - *min_element(s.begin(), s.end());
}

long long f(long long x, long long y)
{
	long long ret = LLONG_MAX;
	vector<long long> h(3), w(3), s(3);
	w[0] = w[1] = w[2] = x;
	for(h[0] = 1; h[0]<=y-2; h[0]++)
	{
		h[1] = (y - h[0]) / 2;
		h[2] = y - h[0] - h[1];
		for(int i=0; i<3; i++)
			s[i] = h[i] * w[i];

		ret = min(ret, dif(s));
	}

	for(h[0] = 1; h[0]<=y-1; h[0]++)
	{
		h[1] = h[2] = y - h[0];
		w[1] = x/2;
		w[2] = x - w[1];
		for(int i=0; i<3; i++)
			s[i] = h[i] * w[i];

		ret = min(ret, dif(s));
	}

	return ret;
}

int main(void)
{
	int H, W;
	cin >> H >> W;

	long long ret = f(H, W);
	ret = min(ret, f(W, H));

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

    long long int n, x, y;
    cin >> n;

    for(int i=1; i<=3500; i++){
      for(int j=1; j<=3500; j++){
        x=n*i*j;
        y=4*i*j-n*i-n*j;
        if(y>0 && x%y==0){
          cout << i << " " << j << " " << x/y << endl;
          return 0;
        }
      }
    }


  return 0;
}

Measured memory_bytes: 384
from fractions import gcd

n = int(input())
as_ = list(map(int, input().split()))

gcd_all = as_.pop()
set_ = {as_[0]}
for a in as_:
    set_ = set(gcd(s, a) for s in set_)
    set_.add(gcd_all)
    gcd_all = gcd(gcd_all, a)

print(max(set_))


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int a1 = 0, a2 = 0;
  REP(i, m){
    int a;
    cin >> a;
    if(a<x) a1++;
    else a2++;
  }
  cout << min(a1, a2) << endl;
  return 0;
}


Measured memory_bytes: 256
#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 x;
    cin >> x;
    int cnt = x / 100;
    int under2 = x % 100;
    if(under2 == 0) {
        cout << 1 << endl;
        return 0;
    }
    if(under2 > 5 * cnt)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

Measured memory_bytes: 3576
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
if N == 1:
    if T[0] == A[0]:
        print(1)
    else:
        print(0)
    exit()

ans = 1
for i in range(1, N - 1):
    if T[i] == T[i - 1] and A[i] == A[i + 1]:
        ans *= min(T[i], A[i])
        ans %= MOD
    elif T[i] > T[i - 1] and A[i] == A[i + 1] and A[i] < T[i]:
        print(0)
        exit()
    elif T[i] == T[i - 1] and A[i] > A[i + 1] and A[i] > T[i]:
        print(0)
        exit()
    elif T[i] > T[i - 1] and A[i] > A[i + 1] and A[i] != T[i]:
        print(0)
        exit()
print(ans)



Measured memory_bytes: 82148
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getArray(N)

def lis(A):
    L = deque([A[0]])
    for a in A[1:]:
        # Lのどの数より小さくければ
        # 繋げられるものがない
        if a <= L[0]:
            L.appendleft(a)
        else:
            # L[bisect_left(L, a) - 1]
            # Lの中のa未満の数字のうちの最大値
            L[bisect_left(L, a) - 1] = a
    return len(L)

print(lis(A))

Measured memory_bytes: 89500
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll k,a,b;
	cin>>k>>a>>b;
	if((b/k)-((a-1)/k)>0)
	cout<<"OK";
	else
	cout<<"NG";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N;
  cin >> N;
  map<string, int> S;
  vector<pair<int, string>> P(N);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    S[s]++;
  }
  int ptr = 0;
  for (auto x : S) {
    P[ptr].first = x.second;
    P[ptr].second = x.first;
    ptr++;
  }
  sort(rall(P));
  vector<string> ans;
  for (int i = 0; i < N; i++) {
    if (P[i].first == P[0].first) {
      ans.push_back(P[i].second);
    }
  }
  sort(all(ans));
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 28656
<?php


fscanf(STDIN, "%d%d", $h, $w);

if($h == 1 || $w == 1){
    echo 1;
}else {
    echo intdiv($h + 1, 2) * intdiv($w + 1, 2)
        + intdiv($h, 2) * intdiv($w, 2);
}

Measured memory_bytes: 4856
#include<iostream>
#include <cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[55];
	int n,k;
	int sum=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=n-1;k>0;k--,i--)
	sum+=a[i];
	printf("%d\n",sum);
	return 0;
} 

Measured memory_bytes: 256
# coding: utf-8

list = []

while True:
    num = input().rstrip().split(" ")
    if int(num[0]) == 0 and int(num[1]) == 0:
        break
    list.append(num)


for i in range(len(list)):
    if int(list[i][0]) <= int(list[i][1]):
        print(str(list[i][0]) + " " + str(list[i][1]))
    else:
        print(str(list[i][1]) + " " + str(list[i][0]))

Measured memory_bytes: 8384
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
vector<pair<int, int>> pairs;
vector<bool> visited;
vector<int> member;
void follow(int i)
{
    visited[i] = true;
    member.push_back(i);
    auto it = lower_bound(pairs.begin(), pairs.end(), make_pair(i, 0));
    auto ite = pairs.end();
    while (it != ite && it->first == i) {
        if (!visited[it->second]) follow(it->second);
        ++it;
    }
}
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> P(N+1);
    for (int i = 1; i <= N; i++) cin >> P[i];
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        pairs.push_back(make_pair(x, y));
        pairs.push_back(make_pair(y, x));
    }
    sort(pairs.begin(), pairs.end());
    visited.resize(N+1);
    int score = 0;
    for (int i = 1; i <= N; i++) {
        if (visited[i]) continue;
        member.clear();
        follow(i);
        vector<bool> bits(N+1);
        for (int m : member) bits[P[m]] = true;
        for (int m : member) if (bits[m]) score++;
    }
    cout << score << endl;
    return 0;
}


Measured memory_bytes: 7152
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (b < 0) {
		if ((b-a) % 2 == 1)cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
	else if (a > 0) {
		cout << "Positive" << endl;
	}
	else {
		cout << "Zero" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < 9 && b < 9) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <list>
#include <algorithm> 

using namespace std;
 
struct crop{
	string name;
	int income;
	int times;
	double effic;
	bool operator<( const crop& right ) const {
        return effic == right.effic ? name < right.name : effic > right.effic;
    }
};

int main(void){
   // FILE* fp_in = freopen("data.txt", "r", stdin);
     
	while( true ) {
		int n;
		cin >> n;
		if( n == 0 ) break;

		vector< crop > crops;
		for(int i = 0; i < n; i++) {
			crop c;
			string s;
			int P, A, B, C, D, E, F, S, M;
			cin >> s ;
			cin >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			c.name = s;
			c.times = A + B + C + ( D + E ) * M;
			c.income = F * M * S - P;
			c.effic = (double) (c.income ) / (double) (c.times);
			crops.push_back( c );
		}

		sort(crops.begin(), crops.end());

		for(int i = 0; i < crops.size(); i++)
			cout << crops[i].name << endl;
		cout << "#" << endl;
	}

	//while(1){}
    return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x,h,th,s;
	
	while(1){
	scanf("%lf",&x);
	scanf("%lf",&h);
	if(x==0&&h==0){
		break;
	}
	th=sqrt(1.0/4.0*x*x+h*h);
	s=(double)x*(double)x+(double)x*(double)th*1.0/2.0*4.0;
	
	printf("%f\n",s);
	}
	
	return 0;
}

Measured memory_bytes: 644
#include<stdio.h>

int main(){

int a,b,c,d=0;

scanf("%d %d %d",&a,&b,&c);

if(a>b){
d=a;
a=b;
b=d;
}
if(b>c){
d=b;
b=c;
c=d;
}
if(a>b){
d=a;
a=b;
b=d;
}
printf("%d %d %d\n",a,b,c);

return 0;
}


Measured memory_bytes: 2044
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt = 0;
		boolean flg = true;
		int max = 32;

		for(int x=0;x<N;x++){
			int num = sc.nextInt();
			int count = 0;
			while(count<max&&num%2!=1){
				num /= 2;
                                count++;
			}
			if(count<max)max=count;
		}

		System.out.println(max);
	}
}

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

int main(){
    int N,M;cin>>N>>M;
    int Lmax=-1;
    int Rmin= 5e+7;
    int L;
    int R;
    for(int i = 0 ;i < M; i++){
        cin >> L >> R;
        if(Lmax <= L && L <= Rmin){
            Lmax=L;
        }
        if(Lmax <= R && R <= Rmin){
            Rmin=R;
        }
        if(L > Rmin || R < Lmax){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << Rmin - Lmax + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <iostream>

using namespace std;
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}

int INF() {
    return numeric_limits<int>::min();
}

int target;
bool f(int v) {
    return v < target;
}

int main(void) {
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    segtree<int, op, INF> seg(A);

    while(Q--) {
        int T;
        cin >> T;
        if(T == 1) {
            int X, V;
            cin >> X >> V;
            --X;
            seg.set(X, V);
        } else if(T == 2) {
            int L, R;
            cin >> L >> R;
            --L, --R;
            cout << seg.prod(L, R+1) << endl;
        } else if(T == 3) {
            int X;
            cin >> X >> target;
            --X;
            cout << seg.max_right<f>(X) + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6112
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> x(5);
    for (int i = 0; i < 5; i++)cin >> x[i];
    for (int i = 0; i < 5; i++) {
        if (x[i] == 0)cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
N = input()
l = ['3', '5', '7']
L = ['3', '5', '7']
temp = []
d = len(N)
N = int(N)


if N - 357 < 0:
    print(0)
    exit()

#d-1桁以下の753数
a = 0
for i in range(3, d):
    a += 3 ** i - 3 * (2 ** i - 2) - 3

#d桁の753数
for k in range(d - 1):
    for i in L:
        for j in l:
            temp.append(i + j)
    L.clear()
    L.extend(temp)
    temp.clear()
L = [i for i in L if '3' in i and '5' in i and '7' in i]

count = 0
for i in L:
    if int(i) <= N:
        count += 1
print(a + count)

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

int gcd(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return gcd(b, a%b);
}

int main() {
    int a, b; cin >> a >> b;
    if(a<0&&b>0){
        a = -a;
        cout << 1 + abs(a-b);
    }else if(a<0&&b<0){
        if(a<=b){
            cout << b-a << endl;
        }else{
        cout << 2 + abs(a-b) << endl;
        }
    }else if(a>0&&b>0){
        if(a<=b){
            cout << abs(a-b) << endl;
        }else{
            cout << 2+abs(a-b) << endl;
        }
    }else if(a>0&&b<0){
        a = -a;
        cout << 1 + abs(a-b);
    }else if(a>0&&b==0){
        cout << 1 + a << endl;
    }else if(a<0&&b==0){
        cout << -a << endl;
    }else if(a==0&&b>0){
        cout << b << endl;
    }else if(a==0&&b<0){
        cout << 1+-b << endl;
    }else if(a==0&&b==0){
        cout << 0 << endl;
    }
    return 0;
}


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

int main(){
    rep(i,5){
        int x;
        cin >> x;
        if(x == 0){
            cout << i+1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
n, m = map(int, input().split())
A = [[0 for i in range(m)] for j in range(n)]

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

b = [0 for i in range(m)]
for i in range(m):
    b[i] = int(input())

for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j] * b[j]
    print(c)

Measured memory_bytes: 7976
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

using P = pair<int, int>;

constexpr int64 MOD = 1000000007;
constexpr int INF = MOD;

struct state {
    int pos, dist;
    state () {}
    state (int a, int b): pos(a), dist(b) {}
    bool operator < (const state &o) const { return dist > o.dist; }
};

struct edge {
    int to, dist, id;
    edge() {}
    edge(int b, int c, int id): to(b), dist(c), id(id) {}
};

int N, M;

vector<vector<edge>> graph;

vector<int> used;

// P = pair< `prev`, `edge_id` >
int main() {
    cin >> N >> M;
    graph.resize(N);
    used.resize(M);
    int edge_id = 0;
    for (int j = 0; j < M; ++j) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        graph[a].emplace_back(b, c, edge_id);
        graph[b].emplace_back(a, c, edge_id);
        edge_id++;
    }

    assert(edge_id == M);
    fill(begin(used), end(used), 0);

    vector<P> prev(N);
    for (int j = 0; j < N; ++j) {
        vector<int> dist(N);
        fill(begin(dist), end(dist), INF);
        fill(begin(prev), end(prev), make_pair(-1, -1));

        priority_queue<state> pq;
        pq.emplace(j, 0);
        dist[j] = 0;
        while (!pq.empty()) {
            state st = pq.top(); pq.pop();
            if (st.dist > dist[st.pos]) { continue; }

            for (const edge& e : graph[st.pos]) {
                if (st.dist + e.dist < dist[e.to]) {
                    dist[e.to] = st.dist + e.dist;
                    prev[e.to] = make_pair(st.pos, e.id);
                    pq.emplace(e.to, dist[e.to]);
                }
            }
        }

        for (int k = 0; k < N; ++k) {
            int pos = k;
            while (pos != j) {
                P p = prev[pos];
                used[p.second] = 1;
                pos = p.first;
            }
        }
    }

    int ans = 0;
    for (int j = 0; j < M; ++j) {
        if (!used[j]) {
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, p;
  cin >> n >> p;
  bool odd = false;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    odd |= x & 1;
  }
  if (odd) cout << (long long) pow(2, n - 1) << endl;
  else {
    if (p == 0) cout << (long long) pow(2, n) << endl;
    else cout << 0 << endl;
  }
  return 0;	
}

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

int n,k,sum;
int p[200005];
double ans;

int main(){

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

    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
        sum+=p[i];
        if(i>=k)sum-=p[i-k];
        ans=max(ans,((double)sum+k)/2);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;

    return 0;
}

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

int main()
{
	int a,m,i;
	int n[256];
	n['I']=1;
	n['V']=5;
	n['X']=10;
	n['L']=50;
	n['C']=100;
	n['D']=500;
	n['M']=1000;

	char s[128];
	while(cin >> s)
	{
		for(a=m=0,i=strlen(s)-1; i>=0; i--)
		{
			if(n[s[i]]<m)	{ a-=n[s[i]]; }
			else			{ a+=m=n[s[i]]; }
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int n,m,sum=0;
	cin>>n>>m;
	if(n>=2)sum+=n*(n-1)/2;
	if(m>=2)sum+=m*(m-1)/2;
	cout<<sum<<endl;
	return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

LL N, Q;
string STR;
LL tbl[100001];

int main()
{
	cin >> N >> Q;
	cin >> STR;

	bool beforeA = false;
	LL acCnt = 0;
	REP(i, N) {
		if (beforeA) {
			if (STR[i] == 'C') {
				++acCnt;
				beforeA = false;
			}
			else {
				if (STR[i] == 'A') {
					beforeA = true;
				}
				else {
					beforeA = false;
				}
			}
		}
		else {
			if (STR[i] == 'A') {
				beforeA = true;
			}
			else {
				beforeA = false;
			}
		}

		tbl[i] = acCnt;
	}

	REP(i, Q) {
		LL s, e;
		cin >> s >> e;

		cout << tbl[e - 1] - tbl[s - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int[] num = new int[2];

			while(true) {
				String[] str = br.readLine().split(" ");
				num[0] = Integer.parseInt(str[0]);
				num[1] = Integer.parseInt(str[2]);

				switch (str[1]) {
				case "+":
					System.out.println(num[0] + num[1]);
					break;
				case "-":
					System.out.println(num[0] - num[1]);
					break;
				case "*":
					System.out.println(num[0] * num[1]);
					break;
				case "/":
					System.out.println(num[0] / num[1]);
					break;
				default:
					break;
				}

				if (str[1].contentEquals("?")) break;
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 24184