akhauriyash/Code-Regression huggingface dataset:
/**
 * File    : B2.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-17 22:50:06
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

double epsilon = 1e-10;

int main()
{
  int N;
  cin >> N;
  int X = floor(sqrt(N) + epsilon);
  cout << X * X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include"custom_header.h"
#else
#define openfile 
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define sz(x) (ll)x.size()
#define vvl vector<vl>
#define vpl vector<pll>
const ll mod = 1000000007;
void solve()
{
    ll n,i,j,ans = 8;cin>>n;
    if(n<600)
    {
        ans = 8;
    }
    else if (n<800)
    {
        ans = 7;
    }
    else if (n<1000)
    {
        ans = 6;
    }
    else if (n<1200)
    {
        ans = 5;
    }
    else if (n<1400)
    {
        ans = 4;
    }
    else if (n<1600)
    {
        ans = 3;
    }
    else if (n<1800)
    {
        ans = 2;
    }
    else
    {
        ans = 1;
    }
    cout<<ans<<endl;
}
int main()
{
    // openfile;fastio;
    ll T = 1; 
    // cin>>T;
    while(T--)
    {solve();}
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <string>

int main() {
  std::string a;
  while (std::cin >> a) {
    if (a[0] == '0')
      break;
    int sum = 0;
    for (int i = 0; i < a.size(); i++)
    {
      sum += a[i] - '0';
    }
    std::cout << sum << "\n";
  }
}


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

int main(){

int  m,f,b; 
cin>>m>>f>>b;

if( m >=b ){cout<< 0 <<endl;}
	else
		if(m + f < b){cout<< "NA" <<endl;}
		else
		{cout<< b-m <<endl;}

return 0;
}



Measured memory_bytes: 3084
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 0;
            foreach (var item in As)
            {

                var tmp = item;
                while (true)
                {
                    if (tmp % 2 == 0)
                    {
                        ret++;
                        tmp = tmp / 2;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 12128
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    
    ll ans = 10000000000001;
    for(ll i=sqrt(N);i>=1;i--){
        if(N%i == 0){
            ans = min(ans,N/i+i-2);
    }
    }
    cout << ans << endl;

return 0;
}


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> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#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 <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x=n/15;
    cout << n*800-x*200 << endl;
}


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

int main(){
long long h,w;
cin >>h  >>w;
//else
  if(h==1 or w==1) cout << 1 <<endl;
  else if(h*w%2==0)cout <<h*w/2 <<endl;
else cout <<(h*w+1)/2 <<endl;

//cout <<ary[k-1] <<endl;

return 0;
}

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

int main()
{
    int m = 0;
    int f = 0;
    int r = 0;
    int total_score = 0;
    
    while (cin >> m >> f >> r)
    {
        if ((-1 == m) && (-1 == f) && (-1 == r))
        {
            break;
        }
        
        if ((-1 == m) || (-1 == f))
        {
            cout << "F" << endl;
            continue;
        }
        
        total_score = m + f;
        if (total_score >= 80)
        {
            cout << "A" << endl;
        }
        else if (total_score >= 65)
        {
            cout << "B" << endl;
        }
        else if (total_score >= 50)
        {
            cout << "C" << endl;
        }
        else if (total_score >= 30)
        {
            if (r >= 50)
            {
                cout << "C" << endl;
            }
            else
            {
                cout << "D" << endl;
            }
        }
        else
        {
            cout << "F" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <vector>
#include <utility>
#include <algorithm>
#define inf 1e9

using namespace std;
typedef pair<int, int> P;

int n, m;
int a[1005][45];
int G[45][45];
int mask[45], mask2[25];
vector<P> vec, vec2;
int dp[1<<20], dp2[1<<20];

void dfs(int p, int l, int r, int s, int cnt, vector<P> &vec)
{
  if(p > r){
    vec.push_back(make_pair(s, cnt));
    return;
  }
  dfs(p+1, l, r, s, cnt, vec);
  if(mask[p] & s) return;
  dfs(p+1, l, r, s|1<<(p-l), cnt+1, vec);
}

int main(void)
{
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j < m; j++) cin >> a[i][j];
    }
    if(m == 1){
      cout << 1 << endl;
      continue;
    }

    for(int i = 0; i < m; i++){
      for(int j = 0; j < m; j++){
        G[i][j] = 0;
      }
    }
    for(int i = 0; i < m; i++){
      for(int j = 0; j < m; j++){
        if(i >= j) continue;
        vector<P> vec;
        for(int k = 1; k <= n; k++){
          vec.push_back(make_pair(a[k][i], a[k][j]));
        }
        sort(vec.begin(), vec.end());
        for(int k = 1; k < vec.size(); k++){
          if(vec[k-1].second > vec[k].second){
            G[i][j] = G[j][i] = 1;
            break;
          }
        }
      }
    }

    /*for(int i = 0; i < m; i++){
      for(int j = 0; j < m; j++){
        cout << G[i][j] << " ";
      }
      cout << endl;
    }*/

    for(int i = 0; i < m/2; i++){
      mask[i] = 0;
      for(int j = 0; j < m/2; j++) if(G[i][j]) mask[i] |= 1<<j;
    }
    for(int i = m/2; i < m; i++){
      mask[i] = 0;
      for(int j = m/2; j < m; j++) if(G[i][j]) mask[i] |= 1<<(j-m/2);
    }

    vec.clear(), vec2.clear();
    dfs(0, 0, m/2-1, 0, 0, vec);
    dfs(m/2, m/2, m-1, 0, 0, vec2);

    int S = 1<<(m/2), S2 = 1<<(m-m/2);
    for(int i = 0; i < S2; i++) dp2[i] = -inf;
    for(int i = 0; i < vec2.size(); i++) dp2[vec2[i].first] = vec2[i].second;
    for(int i = 0; i < S2; i++){
      for(int j = 0; j < m-m/2; j++){
        if(i && 1<<j) dp2[i] = max(dp2[i], dp2[i & ~(1<<j)]);
      }
    }

    for(int i = 0; i < m/2; i++){
      mask2[i] = 0;
      for(int j = m/2; j < m; j++) if(G[i][j]) mask2[i] |= 1<<(j-m/2);
    }

    int ans = 0;
    for(int i = 0; i < vec.size(); i++){
      int adj = 0;
      for(int j = 0; j < m/2; j++) if(vec[i].first & (1<<j)) adj |= mask2[j];
      ans = max(ans, vec[i].second + dp2[((S2-1)-adj)]);
    }
    cout << ans << endl;
  }

  return 0;
}



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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll m = (1ll << n);
	vi v(m);
	REP(i, m)cin >> v[i];
	vvi f(m);
	REP(i, m)f[i] = { v[i],0 };
	REP(i, n) {
		REP(j, m) {
			int k = j | (1 << i);
			if ((j&(1 << i)) == 0) {
				f[k].push_back(f[j][0]);
				f[k].push_back(f[j][1]);
				sort(ALL(f[k]),greater<int>());
				f[k].pop_back();
				f[k].pop_back();
			}
		}
	}
	int tmp = 0;
	FOR(i,1, m) {
		tmp = max(tmp, f[i][0] + f[i][1]);
		cout << tmp << endl;
	}

	

}

Measured memory_bytes: 18432
/*
	- 20.3.2
	H - Grid 1
	Atcoder-Educational DP Contest-H - Grid 1n
	20.3.2-Atcoder-Educational DP Contest-H - Grid 1
	- 
	-
	- 
*/
#include <bits/stdc++.h>
using namespace std;
#define MO 1000000007
int a[1024][1024],f[1024][1024];
int w,h; 
char ch;

int main()
{
	cin>>h>>w;
	for (int i=1;i<=h;++i)
		for (int j=1;j<=w;++j)
		{
			cin>>ch;
			if (ch=='.')
				a[i][j]=1;
		}
	f[0][1]=1;
	for (int i=1;i<=h;++i)
		for (int j=1;j<=w;++j)
			if (a[i][j]==1)
				f[i][j]=(f[i-1][j]+f[i][j-1])%MO;
	cout<<f[h][w]<<endl;
	return 0;
}

Measured memory_bytes: 8448
#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()
#define mod 1000000007
typedef long long ll;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> mp;
  rep(i, h){
    string str;
    cin >> str;
    mp.push_back(str);
  }
  vector<vector<int>> row(h, vector<int>(w, 0));
  vector<vector<int>> col(h, vector<int>(w, 0));
  bool light = false;
  int cnt = 0;
  rep(i, h){
    light = false;
    cnt = 0;
    rep(j, w){
      if(mp[i][j] == '.'){
        if(light){
          cnt++;
        }else{
          light = true;
          cnt = 1;
        }
      }else{
        if(light){
          light = false;
          for(int k=1; k<=cnt; k++) row[i][j-k] = cnt;
        }
      }
    }
    if(light){
      light = false;
      for(int k=1; k<=cnt; k++) row[i][w-k] = cnt;
    }
  }
  light = false;
  cnt = 0;
  rep(j, w){
    light = false;
    cnt = 0;
    rep(i, h){
      if(mp[i][j] == '.'){
        if(light){
          cnt++;
        }else{
          light = true;
          cnt = 1;
        }
      }else{
        if(light){
          light = false;
          for(int k=1; k<=cnt; k++) col[i-k][j] = cnt;
        }
      }
    }
    if(light){
      light = false;
      for(int k=1; k<=cnt; k++) col[h-k][j] = cnt;
    }
  }
  int biggest = 0;
  rep(i, h)
    rep(j, w)
      biggest = max(biggest, row[i][j]+col[i][j]-1);
  cout << biggest << endl;
  return 0;
}

Measured memory_bytes: 35840
N, W = map(int, input().split())
I = [[0, 0]]
I += [list(map(int,input().split())) for _ in range(N)]
dp = [[float('inf')]*(W+1) for _ in range(N+1)]
G = [['']*(W+1) for _ in range(N+1)]

def check():
    for w in range(W+1):
        dp[0][w] = 0
        G[0][w] = 'DIAGNOAL'
    for i in range(1, N+1):
        dp[i][0] = 0
    for i in range(1, N+1):
        for w in range(1, W+1):
            if I[i][1] <= w:
                if I[i][0]+dp[i-1][w-I[i][1]] > dp[i-1][w]:
                    dp[i][w] = dp[i-1][w-I[i][1]]+I[i][0]
                    G[i][w] = 'DIAGNOAL'
                else:
                    dp[i][w] = dp[i-1][w]
                    G[i][w] = 'TOP'
            else:
                dp[i][w] = dp[i-1][w]
                G[i][w] = 'TOP'
        max_value = max(dp[i])
    return max_value

print(check())


Measured memory_bytes: 33420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::vector<int> v, P, Q;
    std::cin >> N;
    for (int i = 1; i <= N; ++i) {
        v.push_back(i);
    }
    for (int i = 0; i < N; ++i) {
        int p;
        std::cin >> p;
        P.push_back(p);
    }
    for (int i = 0; i < N; ++i) {
        int q;
        std::cin >> q;
        Q.push_back(q);
    }


    int i = 0, np = 0, nq = 0;
    do {
        if (v == P) {
            np = i;
        }
        if (v == Q) {
            nq = i;
        }
        ++i;
    } while (std::next_permutation(v.begin(), v.end()));
    std::cout << std::abs(np - nq) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <stdint.h>
#include <vector>

using namespace std;

#define CITIES (2 * 100000)

static vector<uint32_t> roads[CITIES];
static vector<uint32_t> rails[CITIES];
static uint64_t road_connected[CITIES];
static uint64_t rail_connected[CITIES];

static void calc_connected(vector<uint32_t> *routes, uint64_t *connected, uint32_t index, uint32_t color)
{
  if (connected[index] != 0) return;
  connected[index] = color;

  for (uint32_t i = 0; i < routes[index].size(); i++) {
    calc_connected(routes, connected, routes[index][i], color);
  }
}

int32_t main()
{
  uint32_t N, K, L;
  cin >> N >> K >> L;

  for (uint32_t i = 0; i < K; i++) {
    uint32_t p, q;
    cin >> p >> q;
    roads[p - 1].push_back(q - 1);
    roads[q - 1].push_back(p - 1);
  }

  for (uint32_t i = 0; i < L; i++) {
    uint32_t r, s;
    cin >> r >> s;
    rails[r - 1].push_back(s - 1);
    rails[s - 1].push_back(r - 1);
  }

  for (uint32_t i = 0; i < N; i++) {
    calc_connected(roads, road_connected, i, i + 1);
  }

  for (uint32_t i = 0; i < N; i++) {
    calc_connected(rails, rail_connected, i, i + 1);
  }

  map<pair<uint64_t, uint64_t>, uint64_t> counter;

  for (uint32_t i = 0; i < N; i++) {
    pair<uint64_t, uint64_t> index(road_connected[i], rail_connected[i]);
    counter[index]++;
  }

  for (uint32_t i = 0; i < N; i++) {
    if (i != 0) cout << " ";
    pair<uint64_t, uint64_t> index(road_connected[i], rail_connected[i]);
    cout << counter[index];
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 29440
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+2;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int h,w;
	cin>>h>>w;
	vector<string> v;
	string s;
	for(int i=0;i<h;i++){
		cin>>s;
		v.push_back(s);
	}
	int dp[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dp[i][j]=0;
		}
		
	}
	dp[0][0]=1;
	for(int i=1;i<h;i++){
		if(v[i][0]!='#')dp[i][0]=dp[i-1][0];
	}
	for(int i=1;i<w;i++){
		if(v[0][i]!='#')dp[0][i]=dp[0][i-1];
	}
	int mod=1000000007;
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(v[i][j]!='#'){
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h-1][w-1]<<"\n";
	//cout<<z<<"\n";
	return 0;
}

Measured memory_bytes: 5248
def is_same(nums) -> bool:
    return nums[0] == nums[1]


def zorome(source) -> str:
    for i, nums in enumerate(source):
        if i >= len(source) - 2:
            return 'No'
        if is_same(source[i]) and is_same(source[i + 1]) and is_same(source[i + 2]):
            return 'Yes'


def main():
    count = int(input())
    nums = []
    for i in range(count):
        num1, num2 = map(int, input().split())
        nums.append((num1, num2))
    print(zorome(nums))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,t,a,i,h,i0;
    cin >> n >> t >> a;
    double dif = 1000.0,tmp;
    for(i=0;i<n;i++){
        cin >> h;
        tmp = abs(a-t+0.006*h);
        if(tmp < dif){
            dif = tmp;
            i0 = i;
        }
    }
    cout << i0+1 << endl;
    return 0;
}

Measured memory_bytes: 256
def solve():
    A, B, C = map(int, input().split())
    isPoor = False
    
    if A == B and A != C:
        isPoor = True
    
    if A == C and A != B:
        isPoor = True
    
    if B == C and B != A:
        isPoor = True
    
    if isPoor:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solve()

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int l = A+B, r = C+D;
  if(l > r) cout << "Left" << endl;
  else if(l == r) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  char num[1001];

  int i=0;

  int sum=1;

  while(sum!=0){

    sum=0;

    i=0;

    scanf("%c",&num[i]);

    while(num[i]!='\n'){

       i++;

       scanf("%c",&num[i]);

    }

   num[i]='\0';

   i=0;

  while(num[i]!='\0'){

     sum+=num[i]-'0';

     i++;

  }

  if(sum!=0){

    printf("%d\n",sum);

  }

  }

  return 0;

}

 

Measured memory_bytes: 536
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main (){
    FastIO
    lld n, i;
    cin >> n;
    lld A[n];
    lld j, s;
    lld m;
    foi(i,n){
    	cin >> A[i];
    }
    sort(A , A + n);
    m  = MAX;
    for(i = A[0]; i<=A[n-1]; i+=1){
    	s = 0;
    	foi(j,n){
    		s += (A[j]-i)*(A[j]-i);
    	}
    	if (s  < m){
    		m  = s;
    	}
    }
    cout <<m;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 300000;
const int oo = 0x3f3f3f3f;
const int mod = 998244353;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

LL fpm(LL base, LL exp) {
    LL res = 1;
    for(; exp > 0; exp >>= 1) {
        if(exp & 1) 
            res = res * base % mod;
        base = base * base % mod;
    }
    return res;
}

int cnt[4];
char st[N + 5];
LL fac[N + 5], inv[N + 5];

inline LL C(int n, int k) {
    return fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int n, m;
bool a[N + 5], b[N + 5], c[N + 5], d[N + 5];

LL calc() {
    LL pre = 1, res = 0;
    int lu = 0, ld = 0, ru = cnt[2], rd = cnt[3];
    for(int i = 0; i < m; ++i) {
        if(c[i]) lu ++, ru --;
        if(d[i]) ld ++, rd --;
        if(c[i] && d[i]) { (pre <<= 1LL) %= mod; }

        if(c[i] || d[i]) { 
            res = (res + pre*(cnt[1] ? C(cnt[1]+ru+rd - 1, cnt[1] - 1) : (ru + rd == 0))) % mod;
            pre = (pre + (cnt[0] ? C(cnt[0]+lu+ld - 1, cnt[0] - 1) : (lu + ld == 0))) % mod;
        }
    }
    return res;
}

void Input() {
    cin >> n >> m;
    scanf("%s", st); for(int i = 0; i < n; ++i) cnt[0] += (a[i] = st[i] - '0');
    scanf("%s", st); for(int i = 0; i < n; ++i) cnt[1] += (b[i] = st[i] - '0');
    scanf("%s", st); for(int i = 0; i < m; ++i) cnt[2] += (c[i] = st[i] - '0');
    scanf("%s", st); for(int i = 0; i < m; ++i) cnt[3] += (d[i] = st[i] - '0');
    if(!(cnt[0] + cnt[1] + cnt[2] + cnt[3])) puts("1"), exit(0);
}

void Init() {
    fac[0] = 1;
    for(int i = 1; i <= N; ++i) fac[i] = fac[i-1] * i % mod;
    inv[N] = fpm(fac[N], mod - 2);
    for(int i = N; i >= 1; --i) inv[i-1] = inv[i] * i % mod;
}

void Solve() {
    LL Ans = calc();

    swap(n, m); swap(b, c);
    swap(a, d); swap(a, b);
    swap(cnt[0], cnt[3]);
    swap(cnt[1], cnt[2]);
    swap(cnt[0], cnt[1]);

    Ans = (Ans + calc()) % mod;
    printf("%lld\n", Ans);
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    Init();
    Input();
    Solve();

    return 0;
}


Measured memory_bytes: 6528
mod = int(1e9+7)
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(60):
    a = 0
    b = 0
    for j in range(N):
        if A[j] % 2:
            a += 1
        else:
            b += 1
        A[j] //= 2
    ans += a*b*pow(2, i, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 122808
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int n,m;
	cin >> n >> m;
	vector<int> ks[10];
	int p[10];
	for(int i=0;i<m;i++){
		int k;
		cin >> k;
		for(int j=0;j<k;j++){
			int s;
			cin >> s;
			ks[i].push_back(s-1);
		}
	}
	for(int i=0;i<m;i++) cin >> p[i];

	int N = 1<<n;
	int ans = 0;
	for(int i=0;i<N;i++){
		bool ok = true;
		bool state[n];
		for(int j=0;j<n;j++){
			if((i & (1<<j))>0){
				state[j] = true;
			}else{
				state[j] = false;
			}
		}
		for(int j=0;j<m;j++){
			int cnt = 0;
			for(int k=0;k<ks[j].size();k++){
				if(state[ks[j][k]]) cnt++;
			}
			if(cnt%2!=p[j]) ok = false;
		}
		if(ok) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define ar array

void solve() {
}

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

  string S;
  string T;
  cin >> S;
  cin >> T;
  if (T.substr(0, T.length() - 1).compare(S) == 0) {
    if (T.length() - 1 == S.length()) {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  
  printf("No\n");
  return 0;
}


Measured memory_bytes: 3588
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())
ans=0
#print(T)
for i in range(K):
    if T[i]=="r":
        ans+=P
    if T[i]=="s":
        ans+=R
    elif T[i]=="p":
        ans+=S

for i in range(K,N):
    if T[i]!=T[i-K]:
        if T[i]=="r":
            ans+=P
        elif T[i]=="s":
            ans+=R
        elif T[i]=="p":
            ans+=S
    else:
        T[i]=""
print(ans)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    string S,T;
    cin >> S >> T;
    cout << T+S << endl;
    return 0;
}


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

int main(){
    string S;
    cin >> S;
    int dict[26] = {0};
    for (auto s : S) dict[s - 'a'] += 1;

    bool flag = true;
    for (int i = 0; i < 26; ++i){
        if (dict[i] == 0){
            cout << char('a' + i) << endl;
            flag = false;
            break;
        }
    }

    if (flag) cout << "None" << endl;
}


Measured memory_bytes: 512
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007

double calc(int w,int s){
    double ans;
    if(w+s==0)return 0;
    ans=(100*s)/(w+s);
    return ans;
}

int main(){
    int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    int w,s;
    double p;
    double max_p=-1;
    double upper=(double)e/(double)(100+e);
    
    int ans=-1,ans_s=-1;
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            w=100*a*i+100*b*j;
            
            for(int k=0;k<=3000;k+=c){
                for(int l=0;l<=3000;l+=d){
                    s=k+l;
                    if(w+s>f)break;
                    p=(double)s/(double)(w+s);
                    if(max_p<p && p<=upper){
                        ans=s+w;
                        max_p=p;
                        ans_s=s;
                    }
                }
            }
        }
    }
    cout << ans << " " << ans_s << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define inf 1000000007;
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void) {
	int a,b,c,i,j,k;
	scanf("%d %d %d",&a,&b,&c);
	i=(a-c)/(b+c);
	printf("%d\n",i);
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    sort(a, a + n);
    ll *lower_zero = lower_bound(a, a + n, 0);

    vector<pair<ll, ll>> ans;
    ll total;

    if (lower_zero == a) {
        repd(i, 1, n - 1) {
            ans.push_back(make_pair(a[0], a[i]));
            a[0] -= a[i];
        }
        ans.push_back(make_pair(a[n - 1], a[0]));
        total = a[n - 1] - a[0];

    } else if (lower_zero == a + n) {
        rep(i, n - 1) {
            ans.push_back(make_pair(a[n - 1], a[i]));
            a[n - 1] -= a[i];
        }
        total = a[n - 1];

    } else {
        ll num_zero = lower_zero - a;
        repd(i, 1, num_zero) {
            ans.push_back(make_pair(a[n - 1], a[i]));
            a[n - 1] -= a[i];
        }
        repd(i, num_zero, n - 1) {
            ans.push_back(make_pair(a[0], a[i]));
            a[0] -= a[i];
        }
        ans.push_back(make_pair(a[n - 1], a[0]));
        total = a[n - 1] - a[0];
    }

    cout << total << endl;
    rep(i, n - 1) { cout << ans[i].first << " " << ans[i].second << endl; }
    return 0;
}

template <typename T> void output(T a, int precision) {

    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += a[i / 2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4840
N, W = map(int, input().split())
ws = [0]*N
vs = [0]*N

for i in range(N):
  w, v = map(int, input().split())
  ws[i] = w
  vs[i] = v

V = N*(10**3)+1
dp = [[float('inf')]*V for _ in range(N+1)]
# dp[i][j]: i個の品物までを見てjの価値を実現する最小のw
dp[0][0] = 0
temp = 0

for i in range(N):
  w = ws[i]
  v = vs[i]
  for k in range(V):
    if k-v>=0:
      dp[i+1][k] = min(dp[i][k-v]+w, dp[i+1][k])
    dp[i+1][k] = min(dp[i][k], dp[i+1][k])

for j in range(V-1, -1, -1):
  if dp[N][j] <= W:
    print(j)
    exit()

Measured memory_bytes: 314488
import java.io.*;

public class Main {
    public static void main (String[] args) throws Exception {
        String s;

        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));

        s = reader.readLine();

        String[] sl    = s.split (" ");
        final String S = sl[0];
        final String T = sl[1];

        s     = reader.readLine();
        sl    = s.split (" ");
        int A = Integer.parseInt (sl[0]);
        int B = Integer.parseInt (sl[1]);

        final String U = reader.readLine();

        if (S.equals (U)) {
            A--;
        } else {
            B--;
        }

        PrintWriter out = new PrintWriter (System.out);
        out.println (A + " " + B);

        out.flush();
    }
}

Measured memory_bytes: 21204
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    int a, b;
    cin >> a >> b;


    cout << a * b - (a + b) + 1 << endl; 
}



Measured memory_bytes: 256
#include <cstdio>
int main(){
	int H,W;
	while(1){
		scanf("%d %d",&H,&W);
		if(!W&&!H){break;}
		for(int i=0;i<H;i++){
			if(!i||!(i-H+1)){
				for(int j=0;j<W;j++){
					putchar('#');
				}
			}
			else{
				for(int j=0;j<W;j++){
					if(!j||!(j-W+1))putchar('#');
					else putchar('.');
				}
			}
			putchar('\n');
		}
		putchar('\n');
	}
}

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

int main(){
  int n;
  cin >> n;
  long long ans=0;
  for(int i=1; i<=n; ++i){
    if(i%3==0) continue;
    if(i%5==0) continue;
    else ans+= i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

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

	}
	else
		cout << s << endl;
	



}

Measured memory_bytes: 3132
from collections import deque

n,m = map(int,input().split())

E = [[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    E[a].append(b)
    E[b].append(a)

   
check = [0]*n
count = 0
def dfs(i):
    check[i-1] = 1
    result = 0
    if not 0 in check:
        
        return 1
        

    for j in E[i]:
        if check[j-1] == 0:
            check[j-1] = 1
            result += dfs(j)
            check[j-1]=0

    return result


print(dfs(1))


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

int main()
{
	int n;
	cin>>n;
	int a[n];
	int b[n-1];
	for(int i=0;i<n-1;i++)
	{
		cin>>b[i];
	}
	a[0]=b[0];
	a[n-1]=b[n-2];
	for(int i=1;i<n-1;i++)
	{
		a[i]=min(b[i],b[i-1]);
	 } 
	 int ans=0;
	 for(int i=0;i<n;i++) 
	 {
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int n,h[300000],a[300000];
long long int dp[300000];
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i+=1){
	    scanf("%d",&h[i]);
	}
	for(int i=0;i<n;i+=1){
	    scanf("%d",&a[i]);
	}
	int base=1;
	while(base<=n){
	    base<<=1;
	}
	vector<long long int>segtree(2*base);
	for(int i=0;i<n;i+=1){
	    int u=h[i]+base;
	    long long int best=0;
	    while(u>1){
	        if(u%2==1){
	            best=max(best,segtree[u-1]);
	        }
	        u>>=1;
	    }
	    dp[h[i]]=best+a[i];
	    for(int j=base+h[i];j>1;j>>=1){
	        segtree[j]=max(segtree[j],dp[h[i]]);
	    }
	}  
	long long int ans=0;
	for(int i=0;i<=n;i+=1){
	    ans=max(ans,dp[i]);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 8192
h,n=map(int,input().split())
M=[]
maxA=0
for i in range(n):
    a,b=map(int,input().split())
    M.append([a,b])
    maxA=max(maxA,a)

dp=[-1]*(h+maxA+5)
dp[0]=0
for i in range(1,h+maxA+5):
    for m in range(n):
        hp=M[m][0]
        mp=M[m][1]
        if i>=hp and dp[i-hp]!=-1: #体力より多い かつ 前の参照が存在しているとき
            if dp[i]==-1: #まだ更新されてないとき
                dp[i]=dp[i-hp]+mp
            else: #既に値があるとき
                dp[i]=(min(dp[i],dp[i-hp]+mp))

chk=h
while dp[chk]==-1:
    chk+=1
ans=dp[chk]
for i in range(chk+1,h+maxA+5):
    if dp[i]!=-1:
        ans=min(ans,dp[i])
print(ans)

Measured memory_bytes: 42588
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int n,m;
int dp[100000+1];
int maxi=0;
class graph
{
   public:
   unordered_map<int,list<int>> adjlist;
   void add_edge(int u,int v)
   {
       adjlist[u].push_back(v);
   }
   void dfs_helper(int src)
   {    
       dp[src]=0;
       for(auto i:adjlist[src])
       {
           if(dp[i]==-1)
           {
               dfs_helper(i);
           }
           dp[src]=max(dp[src],1+dp[i]);
           if(dp[src]>maxi)
           {
               maxi=dp[src];
           }
       }

   }
   void dfs()
   {
        for(int i=1;i<=n;i++)
        {
            if(dp[i]==-1)
            { //cout<<i<<endl;
                dfs_helper(i);
               // cout<<i.first<<endl;
            }
        }

   }


};
int main()
{
    
    cin>>n>>m;
    fill(dp,dp+n+1,-1);
    graph g;
   
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        g.add_edge(x,y);
        //cout<<"haale";
        
    }
    
     g.dfs();
     cout<<maxi<<endl;


}

Measured memory_bytes: 10788
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

l = list(map(int, input().split()))

counter = 0
while (l[0] != l[1]) or (l[1] != l[2]):
    mi = min(l)
    ma = max(l)
    
    if ma - mi < 2:
        c = len([v for v in l if v == mi])
        if c == 2:
            counter += 1
        else:
            counter += 2
        break
    else:
        counter += (ma - mi) // 2
        for i in range(3):
            if l[i] == mi:
                l[i] += (ma - mi) // 2 * 2
                break
    
print(counter)


Measured memory_bytes: 3064
#!python3

def resolve():
    N, u, v = map(int, input().rstrip().split())
    N1 = N + 1

    d = [[] for _ in range(0, N1)]
    for i in range(1, N):
        a, b = map(int, input().rstrip().split())

        d[a].append(b)
        d[b].append(a)

    from collections import deque

    def f(x):
        q = deque()
        q.append(x)
        X = [-1] * N1

        X[x] = 0
        while q:
            x = q.popleft()
            for i in d[x]:
                if X[i] == -1:
                    X[i] = X[x] + 1
                    q.append(i)
        return X

    U = f(u)
    V = f(v)

    m = 0
    for uu, vv in zip(U, V):
        if uu < vv:
            if vv > m:
                m = vv
    print(m-1)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 29360
#include <iostream>
using namespace std;
int area;
const int maxn=105;
char maze[maxn][maxn];
const int step[][2]={{-1,0},{1,0},{0,-1},{0,1}};
int N,M;
void dfs(int x,int y,char ch){
    maze[x][y]='$';
    for(int i=0;i<4;i++){
        int nx=x+step[i][0],ny=y+step[i][1];
        if(nx>=0&&ny>=0&&nx<N&&ny<M&&maze[nx][ny]==ch){
            dfs(nx,ny,ch);
        }
    }
    return;
}
int main() {
   // freopen("test","r",stdin);
    while(cin>>N>>M&&N+M){
        area=0;
        for(int i=0;i<N;i++)
            for(int j=0;j<M;j++)
                cin>>maze[i][j];

        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
            if(maze[i][j]!='$'){
                char ch=maze[i][j];
                dfs(i,j,ch);
                area++;
            }
            }
        }
        cout<<area<<endl;
    }
    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
using namespace std;
const int MAXN = 20 + 7;
int N, M;
int A[MAXN], rec[MAXN];

bool solve( int cur ) {
    if( cur == N ) {
        int sum = 0;
        for( int i = 0; i < N; i++ ) sum += rec[i] * A[i];
        return sum == M;
    }
    rec[cur] = 1;
    if ( !solve(cur+1) ) {
        rec[cur] = 0;
        return solve( cur+1 );
    }
    else return true;
}


int main( ) {
    int t;
    scanf("%d", &N);
    for ( int i = 0; i < N; i++ ) scanf("%d", &A[i]);
    scanf("%d", &t);
    while( t-- ) {
        scanf("%d", &M);
        if(solve(0)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



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

bool ispossible(int n, int m, int v, int p, const vector<int> &a, int k) {
  if (k == n) return false;
  if (k < p) return true;
  int64_t s = 0;
  for (int i = 0; i < n; i++) {
    if (i < p - 1) {
      s += m;
    } else {
      int d = a.at(k) + m - a.at(i);
      if (d < 0) return false;
      s += min(m, d);
    }
  }
  return s >= (int64_t) m * v;
}

int main() {
  int n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.rbegin(), a.rend());
  int lower_bound = p - 1, upper_bound = n;
  while (upper_bound - lower_bound > 1) {
    int half = (lower_bound + upper_bound) / 2;
    if (ispossible(n, m, v, p, a, half)) {
      lower_bound = half;
    } else {
      upper_bound = half;
    }
  }
  cout << lower_bound + 1 << endl;
}


Measured memory_bytes: 640
/*

0077: run length

*/

#include <stdio.h>
#include <string.h>

int main(void){
	
	char text[256];
	char result[256];
	int i, k, m;
	int times;
	char temp;
	
	while(fgets(text, sizeof(text), stdin) != NULL){
		
		text[strlen(text)-1] = '\0';
		
		i = 0;
		m = 0;
		
		while(text[i] != '\0'){
			
			if(text[i] == '@'){
				
				times = text[i+1] - '0';
				temp = text[i+2];
				
				for(k=0; k<times; k++){
					
					result[m] = temp;
					m++;
					
				}
				
				i+=2;
				
			}
			else{
				
				result[m] = text[i];
				m++;
				
			}
			
			i++;
			
		}
		
		result[m] = '\0';
		
		puts(result);
		
	}
	
	return 0;
	
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;

signed main(){
	IOS();
	cin>>X>>A;
	if(X<A)cout<<0<<endl;
	else cout<<10<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#define N 200009

using namespace std;

int n,m,visit[N];
vector <int> g[N];

int BFS(int src)
{
    queue <int> Q;
    Q.push(src);
    visit[src] = 1;
    int cnt = 1;
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int i=0;i<g[u].size();i++){
            int v = g[u][i];
            if(visit[v]==0){
                cnt++;
                Q.push(v);
                visit[v] = 1;
            }
        }
    }
    return cnt;
}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>> n >> m;
    for(int i=1;i<=m;i++){
        int s,e;
        cin>> s >> e;
        g[s].push_back(e);
        g[e].push_back(s);
    }
    int mx = 0;
    for(int i=1;i<=n;i++){
        if(!visit[i]){
            int cnt = BFS(i);
            mx = max(mx,cnt);
        }
    }
    cout<< mx << endl;

    return 0;
}


Measured memory_bytes: 15716
def main():
    from collections import Counter as ct
    n = int(input())
    x = list(map(int, input().split()))
    a = [1]*n
    for i in range(1, n):
        if i-(x[i-1]-1)//2 > a[i-1]:
            a[i] = max(i-x[i]//2+1, a[i-1]+1)
        else:
            a[i] = max(i-x[i]//2+1, a[i-1])
    c = ct(a)
    mod = 10**9+7
    ans = 1
    cnt = 0
    for i in range(1, n+1):
        cnt += c[i]
        ans = ans*cnt % mod
        cnt -= 1
    print(ans)


main()

Measured memory_bytes: 17604
#include <stdio.h>
#include <algorithm>
#include <tuple>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

constexpr int sz = 200100;
int p[sz], r[sz];
void Init() {
	for (int i = 0; i < sz; i++)
		p[i] = i, r[i] = 1;
}
int root(int x) {
	if (p[x] == x)
		return x;
	return (p[x] = root(p[x]));
}
void unite(int a, int b) {
	a = root(a), b = root(b);
	if (a == b)
		return;
	if (r[a] < r[b])
		swap(a, b);
	p[b] = a;
	r[a] += r[b];
}

int n, k, l, v[sz];
pii u[sz];
int main() {
	scanf("%d %d %d", &n, &k, &l);

	Init();
	for (int i = 0; i < k; i++) {
		int p, q;
		scanf("%d %d", &p, &q);
		unite(p, q);
	}
	for (int i = 1; i <= n; i++)
		u[i].first = root(i), u[i].second = i;

	Init();
	for (int i = 0; i < l; i++) {
		int p, q;
		scanf("%d %d", &p, &q);
		unite(p, q);
	}
	for (int i = 1; i <= n; i++)
		u[i].first = u[i].first * sz + root(i);
	sort(u + 1, u + n + 1);

	for (int i = 1; i <= n; ) {
		int sz = 0;
		for (int j = i; j <= n; j++, sz++)
			if (u[i].first != u[j].first)
				break;
		for (int j = i; j <= n; v[u[j++].second] = sz)
			if (u[i].first != u[j].first)
				break;
		i += sz;
	}

	for (int i = 1; i <= n; i++)
		printf("%d\n", v[i]);
}

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

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = x2 + (y1-y2);
    y3 = y2 - (x1-x2);
    x4 = x1 - (y2-y1);
    y4 = y1 + (x2-x1);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
import itertools
S=[]
for i in range(1,150):
    for j in range(1,i):
        S.append((i*i+j*j,j,i))
S.sort()
while True:
    h,w=map(int, input().split())
    if h==0 and w==0:
        exit()
    s = S[S.index((w*w+h*h,h,w))+1]
    print(s[1],s[2])

Measured memory_bytes: 8660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      exit(0);
    }
  }
  cout << "Three" << endl;
}


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

int main(){
  double S,x,h;

  for(;;){
    cin >> x >> h;
    if(x == 0 && h == 0) break;

    S = (sqrt(h*h+x*x/4)*2+x)*x;
    printf("%.6f\n" ,S);
  }

  return 0;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int mod=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

const int maxn=303;

int n,m,l,a,b,c;
ll d[maxn][maxn],tt[maxn][maxn];
void floyd(ll dp[303][303]){rep(k,1,n+1)rep(i,1,n+1)rep(j,1,n+1)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);}

int main(){
	ll n,a[2*M],f[2*M];
	ll k,asum=0;
	cin>>n>>k;
	rep(i,0,n)cin>>a[i],asum+=a[i];
	rep(i,0,n)cin>>f[i];
	sort(a,a+n);sort(f,f+n,greater<>());

	if(asum<=k)print(0);
	else{
		ll l=-1,r=INF,mid=(l+r)/2;
		while(r>l+1){
			mid=(l+r)/2;
			ll atmp=0;
			rep(i,0,n)
				atmp+=max(a[i]-mid/f[i],(ll)0);
			if(atmp<=k)r=mid;
			else l=mid;
		}
		print(l+1);
	}
}

Measured memory_bytes: 3328