akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{

int num,len;
cin>>num>>len;
vector<string> x;
string s;
while(num--)
{
cin>>s;
x.push_back(s);
}
sort(x.begin(),x.end());
vector<string>::iterator itr;
for(itr=x.begin();itr<x.end();itr++)
cout<<*itr;
return 0;
}

Measured memory_bytes: 256
a=gets.to_i
b=gets.to_i
c=gets.to_i
x=gets.to_i
cnt=0
for i in 0..a
    for j in 0..b
        for k in 0..c
            if 500*i+100*j+50*k==x
                cnt+=1
            end
        end
    end
end

p cnt

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int w = scan.nextInt();
			int h = scan.nextInt();
			if(w == 0 && h == 0){
				break;
			}
			char[][] tile = new char[w][];
			for(int i = 0;i < w;i++){
				tile[i] = scan.next().toCharArray();
			}
			int i = 0;
			int j = 0;
			boolean[][] fl = new boolean[w][h];
			while(true){
				if(fl[i][j]){
					System.out.println("LOOP");
					break;
				}
				fl[i][j] = true;
				if(tile[i][j] == '.'){
					System.out.println(j + " " + i);
					break;
				}else if(tile[i][j] == '>'){
					j++;
				}else if(tile[i][j] == '<'){
					j--;
				}else if(tile[i][j] == '^'){
					i--;
				}else if(tile[i][j] == 'v'){
					i++;
				}
			}
		}
	}
}

Measured memory_bytes: 22304
a,b=map(int,input().split())

ansa=str(a)
ansb=str(b)

for i in range(b-1):
    ansa=ansa+str(a)
for i in range(a-1):
    ansb=ansb+str(b)

A=[]
A.append(ansa)
A.append(ansb)

A.sort()
print(A[0])



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

ll calc(ll x){
    if(x<=0)return  0;
    x++;//0から数えるから帳尻合わせ
    ll ans=0;
    for (int i = 0; i < 50; ++i) {
        ll loop=(1LL<<(i+1));//周期
        ll co=(x/loop)*(loop/2);//ループした回数＊１の数
        co+=max(0LL,(x%loop)-(loop/2));//00001111 -に注意
        if(co%2==1){
            ans+=(1LL<<i);
        }
    }
    return ans;
}

int main(){
    ll a,b;cin >>a>>b;
    ll ans=calc(b)^calc(a-1LL);
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    A.push_back(0);
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }
    A.push_back(0);

    int64_t sum = 0;
    for (size_t i = 1; i < A.size(); ++i) {
        sum += std::abs(A[i] - A[i-1]);
    }

    for (size_t i = 1; i < A.size() - 1; ++i) {
        auto diff = sum - std::abs(A[i] - A[i-1]) - std::abs(A[i+1] - A[i]) + std::abs(A[i+1] - A[i-1]);
        std::cout << diff << std::endl;
    }

    return 0;
}


Measured memory_bytes: 2164
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<vector<int>> in(n+1, vector<int>(3));
    for (int i=1; i<n+1; i++) {
        cin >> in.at(i).at(0) >> in.at(i).at(1) >> in.at(i).at(2);
    }
    for (int i=1; i<n+1; i++) {
        int time = in.at(i).at(0) - in.at(i-1).at(0);
        int dis = abs(in.at(i).at(1) - in.at(i-1).at(1)) + abs(in.at(i).at(2) - in.at(i-1).at(2));
        if (dis > time) {
            cout << "No" << endl;
            return 0;
        }
        else {
            if (dis%2 != time%2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  ll dp[n+1]={};
  for(i=0;i<m;i++){
    ll l,r;
    cin >> l >> r;
    dp[l]++;
    dp[r+1]--;
  }
  for(i=0;i<n;i++){
    dp[i+1]+=dp[i];
  }
  ll ret = 0;
  for(i=0;i<=n;i++){
    if(dp[i]==m)ret++;
    //cout << dp[i] << " ";
  }
  //cout << endl;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e6+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int x;
    cin>>x;
    cout<<(x>=30?"Yes":"No");

}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int x;

int main(){
	cin>>x;
	if(x<1200) cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

ll n,p;

ll numDivisors(ll p) {
	ll res = 1;
	for (ll i = 2; i * i <= p; ++i) {
		if (p % i == 0) {
			ll cnt = 0;
			while (p % i == 0) { 
				p /= i; 
				++cnt; 
			}
			cnt/=n;
			while(cnt--)
				res*=i;
		}
	}
	return res;
}

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

	cin >> n >> p;

	if(n==1)
		cout << p << endl;
	else
		cout << numDivisors(p) << endl;   

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        UnionFind uf = new UnionFind(n);
        while (m-- > 0) {
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            
            uf.unite(a,b);
        }
        
        // 10こある
        // 連結成分8ko
        System.out.println(uf.connectedComponent-1);
    }
}

class UnionFind {
    int[] par;  // 自身の親
    int[] size; // ※(自身の属するグループの要素数はsize[uf.root(i)]。)
                // (※[i]全てに対して↑を更新するのは時間がかかるので)
    int connectedComponent;

    UnionFind(int n) {
        par = new int[n];
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
        
        size = new int[n];
        Arrays.fill(size, 1);
        connectedComponent = n;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
        // 1-2-4の場合、4の親=2を4の根=1に繋ぎ変えた上で親を返す
        // ↑根まで辿る深さ(計算量)を減らす為
        // return a = b;とは、aにbを代入し、aを返すという意味
    }
    
    // 点x, yを連結させる=同じグループにする
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            par[ry] = rx;
            
            int resize = size[rx] + size[ry];
            size[rx] = resize;
            size[ry] = resize;
            connectedComponent--;
        }
    }
    
    // 同グループか否か
    boolean same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
}

Measured memory_bytes: 59912
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<vector<int>> mat(n, vector<int>(n, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> mat[i][j];
        }
    }
    vector<ll> dp(1<<n, 0);
    auto compute = [&](int num) -> ll {
        vector<int> idx;
        for(int i = 0; i < n; i++) {
            if ((num >> i) & 1) {
                idx.push_back(i);
            }
        }
        ll res = 0;
        for(int i = 0; i < idx.size(); i++)
            for(int j = i+1; j < idx.size(); j++)
                res += mat[idx[i]][idx[j]];
        return res;
    };
    auto sub = [&](auto self, vector<int>& arr, int d, int sub, int orig) -> ll {
        if (d == arr.size()) {
            int tmp = (orig ^ sub);
            // printf("num %d = (%d, %d)\n", orig, sub, tmp);
            return dp[tmp] + dp[sub];
        }
        ll res1 = self(self, arr, d+1, sub, orig);
        ll res2 = self(self, arr, d+1, sub+(1<<arr[d]), orig);
        return max(res1, res2);
    };
    ll ans = 0;
    for(int state = 0; state < (1<<n); state++) {
        dp[state] = max(dp[state], compute(state));
        vector<int> idx;
        for(int i =0 ; i < n; i++) {
            if ((state >> i) & 1) {
                idx.push_back(i);
            }
        }
        if (idx.size() > 0)
            dp[state] = max(dp[state], sub(sub, idx, 0, 0, state));
        ans = max(ans, dp[state]);
    }
    cout << ans << endl;
    return 0;
}




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

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

	map<int, int> m;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;

		if (m[a] > 0)
		{
			cout << "NO";
			return 0;
		}

		++m[a];
	}
	cout << "YES";

	return 0;
}


Measured memory_bytes: 9600
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
two=0
a=Counter(A)
for k,v in a.items():
  if v==2:
    two=k
LR=[]
for i in range(N+1):
  if A[i]==two:
    LR.append(i)
L=LR[0]
R=LR[1]
mod=10**9+7
P=[1 for i in range(10**6+1)]
for i in range(10**6):
  P[i+1]=P[i]*(i+1)%mod
L+=1
R+=1
def comb(a,b):
  if a>=b:
    return P[a]*pow(P[a-b],mod-2,mod)*pow(P[b],mod-2,mod)%mod
  else:
    return 0

for i in range(1,N+2):
  print((comb(N+1,i)-comb(N+L-R,i-1))%mod)

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

int main() {
    int k, s, ans = 0;
    cin >> k >> s;
    for (int x = 0; x < k+1; x++) {
        for (int y = 0; y < k+1; y++) {
            if ((s - x - y) >= 0 && (s - x - y) <= k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
  int n,i,c=0;
  char a[11];
  scanf("%s",a);
  scanf("%d",&n);
  char b[n][22];
  for(i=0;i<n;i++){
    scanf("%s",b[i]);
    strcat(b[i],b[i]);
    if(strstr(b[i],a)!=NULL)
      c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 616
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        System.out.println(a < 10 && b < 10 ? a * b : -1);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
typedef pair<P,int>P1;
#define fi first
#define sc second

vector<P1>query;
typedef long long ll;
int n;
//いまからスタートです
int main(){
    cin >> n;
    cout << (n-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, M, C, b, a;
    cin >> N >> M >> C;
    int B[M];
    for(int i = 0; i < M; ++i){
        cin >> B[i];
    }
    int ans = 0;
    for(int i = 0; i < N; ++i){
        int score = 0;
        for(int j = 0; j < M; ++j){
            cin >> a;
            score += a*B[j];
        }
        score += C;
        if(score > 0){
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> N;
  vvi work(N,vi(2));
  int crt = 0;
  rep(i,N){
    cin >> work[i][1] >> work[i][0];
    crt += work[i][1];
  }
  sort(all(work));
  reverse(all(work));  
  
  if(crt > work[0][0]) {Yes(0); return 0;}
  else crt = work[0][0];
  rep(i,N){
    if(crt<=work[i][0]) crt -= work[i][1];
    else crt = work[i][0]-work[i][1];
  }
  Yes(crt>=0);
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

bool solve(int N, vi& t, vi& x, vi& y) {
    int at=0, ax=0, ay=0;
    rep(i, N){
        int dt=t[i]-at, dx=x[i]-ax, dy=y[i]-ay, d=dx+dy;
        at=t[i]; ax=x[i]; ay=y[i];
        if (d > dt) return false;
        // d <= dt
        if ((dt - d) % 2) return false;
    }
    return true;
}

int main() {
    int N; cin >> N;
    vi t(N), x(N), y(N);
    rep(i,N) cin >> t[i] >> x[i] >> y[i];
    cout << (solve(N,t,x,y) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >>n>>k;
    int x=n/k;
    int i=1,p=1;
    while(1)
    {
        if(p>=n)break;
        p=k*i;i++;
    }
    int y=p/k;
    cout <<abs(y-x)<<endl;
//    bool ok=0;
//    while(1)
//    {
//        if(!n){ok=1;break;}
//        if(n<4){ok=0;break;}
//        else if(n%4==0){n/=4;ok=1;break;}
//        else if(n%7==0){n/=7;ok=1;break;}
//        else if(n>=7){n-=7;}
//        else if(n>=4){n-=4;}
//    }
//    cout <<((ok)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    char b; cin >> b;

    if(b == 'A') dunk('T');
    if(b == 'T') dunk('A');
    if(b == 'G') dunk('C');
    if(b == 'C') dunk('G');
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int>A(q);
    rep(i,q)cin>>A[i];
    vector<int>B(n,k-q);
    rep(i,q)B[A[i]-1]++;
    rep(i,n){
    if(B[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }

return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();
		System.out.println(Math.max(a * b,  c * d));
	}
}

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

class Main{
	static long GCD(long x, long y) {
		if(y == 0) return x;
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static int GCD(int x, int y) {
		return (int)GCD((long)x, (long)y);
	}
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) A[i] = sc.nextInt();
		Arrays.sort(A);
		for(int i = 1; i < N; i++) A[i] %= A[0];
		int ans = A[0];
		for(int i = 1; i < N; i++) {
			ans = Math.min(ans, GCD(A[0], A[i]));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 49320
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

L = input()
n = len(L)
L = "@" + L


dp = [[0,0] for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    if L[i+1] == "0":
        dp[i+1][0] = dp[i][0] % mod
        dp[i+1][1] = 3*dp[i][1] % mod
    else:
        dp[i+1][0] = 2*dp[i][0] % mod
        dp[i+1][1] = (dp[i][0] + 3*dp[i][1]) % mod

print((dp[n][0]+dp[n][1]) % mod)

Measured memory_bytes: 88224
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int w, h, n;
    cin >> w >> h >> n;
    int l = 0, r = w, d = 0, u = h;
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            chmax(l, x);
        } else if (a == 2) {
            chmin(r, x);
        } else if (a == 3) {
            chmax(d, y);
        } else {
            chmin(u, y);
        }
    }
    if (l < r && d < u) cout << (r - l) * (u - d) << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k; cin >> k;
    int ans = 1;
    for (int mod = 7; mod % k; mod = (mod * 10 + 7) % k)
        if (++ans > k) { ans = -1; break; }
    cout << ans << "\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> b(n);
    rep(i,n) cin>>b[i];
    stack<int> c;
    rep(k,n){
        for(int i=b.size()-1;i>=0;i--){
            if(b[i]==i+1){
                c.push(b[i]);
                b.erase(b.begin()+i);
                break;
            }
        }
    }
    if(c.size()!=n){
        cout<<-1<<endl;
        return 0;
    }
    while(c.size()){
        cout<<c.top()<<endl;
        c.pop();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {

fast();

{
  int n,a=0,b;
  cin>>n;
  a+=n%10;
  n/=10;
  a+=n%10;
  n/=10;
  a+=n%10;
  
  cout<<a<<endl;

}
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[60],t[60];
int n,m;
bool check(int k,char ch)
{
	for(int i=k;i<m+k;i++)
		if(s[i]!=t[i-k]&&s[i]!=ch)return 0;
	return 1;
}
int main()
{
	scanf("%s%s",s,t);
	n=strlen(s);
	m=strlen(t);
	for(int i=0;i<n;i++)
		if(check(i,' '))
		{
			for(int j=0;j<n;j++)
				if(s[j]=='?')s[j]='a';
			puts(s);
			return 0;
		}
	for(int i=n-m;i>=0;i--)
		if(check(i,'?'))
		{
			for(int j=i;j<i+m;j++)s[j]=t[j-i];
			for(int j=0;j<n;j++)
				if(s[j]=='?')s[j]='a';
			puts(s);
			return 0;
		}
	puts("UNRESTORABLE");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i, n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}


signed main() {
	int n;
	cin >> n;
	rep(i, 9) {
		rep(j, 9) {
			if ((i + 1) * (j + 1) == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }
    static long GCD(long x,long y)
    {
        if (y == 0) return x;
        return GCD(y, x % y);
    }

    static long LCM(long x,long y)
    {
        return x * y / GCD(x, y);
    }


    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        bool ac = true;
        string S = sc.str;
        if (S[0] != 'A') ac = false;
        bool isC = false;
        int Ci = -1;
        for (int i = 2; i < S.Length - 1; ++i)
        {
            if (!isC && S[i] == 'C')
            {
                isC = true;
                Ci = i;
            }
            else if (isC && S[i] == 'C')
            {
                ac = false;
            }

        }
        if (!isC) ac = false;
        for (int i = 0; i < S.Length; ++i)
        {
            if (i != 0 && i != Ci)
            {
                if (S[i] < 'a')
                {
                    ac = false;
                }
            }
        }
        if (ac) wr.wri("AC");
        else wr.wri("WA");
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <sstream>
#include <deque>
#define ll long long
using namespace std;


int main(){

	ll n;
	cin>>n;
	for(ll a=1;a<=3500;a++){
		for(ll b=1;b<=3500;b++){
			ll rhs=a*n*b;
			ll lhs=(4*a*b)-(b*n)-(a*n);

			if(lhs>0)

				if(rhs%lhs==0){
					ll out=rhs/lhs;
					cout<<out<<" "<<a<<" "<<b;
					return 0;
				}

		}
	}



}

Measured memory_bytes: 256
#include <cstdio>

const char pat3[3][4]={"a..",
		       "a..",
		       ".aa"};
const char pat4[4][5]={"aacd",
		       "bbcd",
		       "cdaa",
		       "cdbb"};
const char pat5[5][6]={"..def",
		       "..def",
		       "aaggh",
		       "bbj.h",
		       "ccjii"};
const char pat6[6][7]={"aacd..",
		       "bbcd..",
		       "..aacd",
		       "..bbcd",
		       "cd..aa",
		       "cd..bb"};
const char pat7[7][8]={"abc....",
		       "abc....",
		       "def....",
		       "def....",
		       "m..gghh",
		       "m..iijj",
		       ".nnkkll"};
		       
char grid[1005][1005];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      grid[i][j]='.';
    }
  }
  if(N==2){
    printf("-1\n");
  }else if(N==3){
    for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      printf("%c",pat3[i][j]);
    }
    printf("\n");
    }
  }else{
    int index=0;
    while(N-index>7){
      for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	  grid[index+i][index+j]=pat4[i][j];
	}
      }
      index+=4;
    }
    if(N-index==4){
      for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	  grid[index+i][index+j]=pat4[i][j];
	}
      }
    }else if(N-index==5){
      for(int i=0;i<5;i++){
	for(int j=0;j<5;j++){
	  grid[index+i][index+j]=pat5[i][j];
	}
      }
    }else if(N-index==6){
      for(int i=0;i<6;i++){
	for(int j=0;j<6;j++){
	  grid[index+i][index+j]=pat6[i][j];
	}
      }
    }else if(N-index==7){
      for(int i=0;i<7;i++){
	for(int j=0;j<7;j++){
	  grid[index+i][index+j]=pat7[i][j];
	}
      }
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	putchar(grid[i][j]);
      }
      printf("\n");
    }
  }
}


Measured memory_bytes: 2176
#include <cstdio>
using namespace std;
int main() {
	char tmp = 0;
	int total = 0;
	int count = 0;
	char pata = '0';
	while (1) {
		scanf("%c", &tmp) + 1;
		if (tmp == '\n') break;
		total++;
		if (tmp == pata) count++;
		pata = (pata == '0') ? '1' : '0';
	}

	printf("%d", (count > total - count) ? total - count : count);

	return 0;
}


Measured memory_bytes: 128
#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);
  vector<int> cnt(200005);
  rep(i,n){
    cin >>a[i];
    cnt[a[i]]++;
  }
  sort(cnt.begin(), cnt.end());
  reverse(cnt.begin(), cnt.end());
  if(cnt[k]==0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  for(int i = k;; i++){
    ans += cnt[i];
    if(cnt[i]==0){
      cout << ans << endl;
      return 0;
    }
  }
  return 0; 
}

Measured memory_bytes: 4852
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,X:usize,M:usize
  }
  let mut a = vec![0; M +1];
  let mut r = vec![M*2; M +1];
  a[0] = X;
  let mut start = 0;
  let mut end = 0;
  for i in 0..M  {
    r[a[i]] = i;
    a[i + 1] = a[i] * a[i] % M;
    if r[a[i + 1]] != M*2 {
      start = r[a[i+1]];
      end = i + 1;
      break;
    }
  }

  if end == 0 {
    let mut ans = 0;
    for i in 0..N {
      ans += a[i];
    }
    println!("{}", ans);
    return;
  }
  let mut ans = 0;
  for i in 0..start {
    ans += a[i];
  }
  let mut some = 0;
  for i in start..end {
    some += a[i];
  }
  let rep = (N - start) / (end - start);
  let amari = (N - start) % (end - start);
  ans += rep * some;
  for i in start..(start + amari) {
    ans += a[i];
  }
  println!("{}", ans);
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k <= a)
    {
        cout << k << endl;
    }
    else if(k <= a + b)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - (k - a - b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, k;
        cin >> n >> k;
        if(n == 0)
            return 0;

        vector<bool> card(n+1, false);
        for(int i=0; i<k; ++i){
            int a;
            cin >> a;
            card[a] = true;
        }

        int ret = 0;
        int l1 = 0;
        int l2 = 0;
        for(int i=1; i<=n; ++i){
            if(card[i]){
                ++ l1;
                ++ l2;
            }else{
                l2 = l1 + 1;
                l1 = 0;
            }
            ret = max(ret, l1);
            if(card[0])
                ret = max(ret, l2);
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
X,N = map(int,input().split())
if N ==0:
    a = X
else:
    p = list(map(int,input().split()))
    i = 0
    while True:
        if not X-i in p:
            a = X-i
            break
        elif not X+i in p:
            a = X+i
            break
        else:
            i = i+1
print(a)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string S; cin >> S;
  
  sort(all(S));
  rep(i,S.size()) {
    for(char c = 'a'; c <= 'z'; c++) {
      if (!count(all(S),c)) {
        cout << c << endl;
        return 0;
      }
    }
  }
  cout << "None" << endl;
}


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

int main(){

    int n,k,a;
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a;
    a = 1 + ((n-k)/(k-1));
    if(((n-k)%(k-1)))a++;
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
[X, N] = list(map(int, input().split()))
A = []
try:
  P = list(map(int, input().split()))
  list_int = [x for x in range(0, 102)]
  list_int_d = list(set(list_int) - set(P))
  list_int_d.sort()
  for i in list_int_d:
    A.append(abs(X - i))
  if 0 in A:
    print(X)
  else:
    Index = A.index(min(A))
    print(list_int_d[Index])
except EOFError:
  print(X)

Measured memory_bytes: 9152
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#endif

#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;

int main() {
	fastIO;
	int x, y;
	cin >> x >> y;
	vector<int> v(x);
	for (int i = 0; i < x; i++) cin >> v[i];
	int sum = 0;
	sort(all(v));
	for (int i = x - 1; i >= x - y; i--) sum += v[i];
	cout << sum;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

 

using namespace std;

 

int main()
{
    int a;
    int b;
    cin >> a >> b;
    if (a > b)
       cout << "a > b" << endl;
    else if (a < b)
       cout << "a < b" <<endl;
    else
       cout << "a == b" << endl;
     
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	int x,y;cin>>x>>y;
	vector<int> v_x;
	vector<int> v_y;
	int tmp = 0;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if (s[i] == 'F'){
			tmp++;
		}
		else{
			if (cnt % 2 == 0){
				v_x.pb(tmp);
				cnt++;
				tmp = 0;
			}
			else{
				v_y.pb(tmp);
				cnt++;
				tmp = 0;
			}
		}
	}
	// if (cnt % 2 == 0){
	// 		v_x.pb(tmp);
	// 	}
	// 	else{
	// 		v_y.pb(tmp);
	// 	}
	if (tmp != 0){
		if (cnt % 2 == 0){
			v_x.pb(tmp);
		}
		else{
			v_y.pb(tmp);
		}
	}
	vector<vector<bool>> dp(10000,vector<bool>(20000,false));
	dp[0][10000] = true;
	int n = v_x.size();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 20000; j++) {
			if (dp[i][j]){
				if (i == 0){
					dp[i + 1][j + v_x[0]] = true;
				}
				else{
					dp[i+1][j + v_x[i]] = true;  
					dp[i+1][j - v_x[i]] = true;  
				}
			}
		}
	}
	if (!dp[n][10000 + x]){
		cout << "No" << endl;
		return 0;
	}

	vector<vector<bool>> dp2(10000,vector<bool>(20000,false));
	dp2[0][10000] = true;
	n = v_y.size();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 20000; j++) {
			if (dp2[i][j]){
				dp2[i+1][j + v_y[i]] = true;  
				dp2[i+1][j - v_y[i]] = true;  
			}
		}
	}
	// for(int i = -15; i < 15; i++) {
	// 	cout << dp2[n % 2][10000 + i] << endl;
	// }
	// for(int i = 0; i < n; i++) {
	// 	cout << v_y[i] << endl;
	// }
	if (!dp2[n][10000 + y]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	// for(int i = -15; i < 15; i++) {
	// 	cout << dp2[n % 2][10000 + i] << endl;
	// }
	// for(int i = 0; i < n; i++) {
	// 	cout << v_y[i] << endl;
	// }

	return 0;
}

Measured memory_bytes: 50176
#include <stdio.h>

int main(void){
  int N, M, X, Y, i, max, min;
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  int x[N], y[M];
  for(i=0; i<N; i++){
    scanf("%d", &x[i]);
    if(i == 0){
      max = x[i];
    }else{
      if(max < x[i]){
        max = x[i];
      }
    }
  }
  for(i=0; i<M; i++){
    scanf("%d", &y[i]);
    if(i == 0){
      min = y[i];
    }else{
      if(min > y[i]){
        min = y[i];
      }
    }
  }
  if(min - max > 0 && (Y - min > 0 && max - X > 0)){
    printf("No War\n");
  }else{
    printf("War\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
 
int main(){
    while(1){
    int x,y,z,dp[50][50]={0};
    cin>>x>>y;
    if(x==0 && y==0)break;
    cin>>z;
    for(int i=0;i<z;++i){
        int xx,yy;
        cin>>xx>>yy;
        dp[xx][yy]=-1;
        }
    for(int i=1;i<=x;i++){
        for(int j=1;j<=y;j++){
            if(dp[i][j]!=-1){
                int xxx,yyy;
                xxx=dp[i][j-1];
                yyy=dp[i-1][j];
                if(xxx==-1)dp[i][j]=yyy;
                else if(yyy==-1)dp[i][j]=xxx;
                else dp[i][j]=xxx+yyy;
                }
                if(i==1 && j==1)dp[i][j]=1;
            }
        }
    cout<<dp[x][y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  int N; cin >> N;
  vector<ll> a(N);
  REP(i, N) cin >> a[i];
  a.PB(0);

  ll cnt = 0, ans = 0;
  REP(i, N + 1) {
    if (a[i] == 0) {
      ans += cnt / 2;
      cnt = 0;
    } else {
      cnt += a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, A, B int

func main() {
	sc.Split(bufio.ScanWords)

	N, A, B = nextInt(), nextInt(), nextInt()

	fmt.Println(maxInt(0, (A+B*(N-1))-(A*(N-1)+B)+1))
}


Measured memory_bytes: 1772
R, G, B, N = map(int, input().split())
r, g, b = 0, 0, 0
ans = 0
 
for r in range(N//R+1):
    Rr = R*r
    for g in range(N//G+1):
        Gg = G*g
        Bb = N-Rr-Gg

        if Bb < 0:
            break
        if Bb%B == 0:
            ans += 1
 
print(ans)

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

int main(){
	int n,l;
	std::cin >>n>>l ;
	std::vector<string> s(n);
	rep(i,n)std::cin >> s[i];
	sort(all(s));
	rep(i,n)std::cout << s[i];
	std::cout << std::endl;
	
}
	

Measured memory_bytes: 256