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

using namespace std;

int main() {
    int a, b, h, m, i;
    long double x, pi=3.1415926535897932384626;
    cin>>a>>b>>h>>m;
    
    
    x=(long double)a*a+(long double)b*b-(long double)2*a*b*cos(pi/180*(30*h-(long double)11/2*m));
    x=(long double)sqrt(x);
    printf("%.15Lf", x);
    return 0;
}

Measured memory_bytes: 4152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 1e5 + 10;
int N;
int A, c[MAXN];

int main() {
	register int i; int x;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i)
		scanf("%d", &x), ++c[x], A = max(A, x);
	if((c[A] + c[A - 1] == N && c[A - 1] < A && (A - c[A - 1]) * 2 <= c[A]) || (c[A] == N && A == N - 1))
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main(void) {
  long long N, M;
  cin >> N >> M;
  map<int, int> wa;
  map<int, int> flag;  // 1以上ならacしている
  for (int i = 0; i < M; i++) {
    int p;
    string S;
    cin >> p >> S;
    p--;
    if (flag[p] == 0 && S == "WA") wa[p]++;
    if (S == "AC") flag[p]++;
  }
  int ans = 0;
  int ac = 0;
  for (auto m : flag) {
    if (m.second >= 1) ac++;
  }
  for (auto m : wa) {
    if (flag[m.first] >= 1) {
      ans += m.second;
    }
  }
  cout << ac << " " << ans << endl;
  return 0;
}

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


#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main() {
    int i,n,k;
    c_p_c();
    cin>>n;
    int l=n%1000;
    if(l==0)
    	cout<<0<<endl;
    else
    cout<<1000-l<<endl;


    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

struct ORD {
  int x1, y1, x2, y2;
};

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

  int H, W;
  cin >> H >> W;
  vector<vector<int>> grid(H, vector<int> (W));
  vector<vector<bool>> done(H, vector<bool> (W, false));
  rep(i, 0, H) {
    rep(j, 0, W) {
      cin >> grid[i][j];
    }
  }

  vector<ORD> ans;

  rep(i, 0, H) {
    rep(j, 0, W-1) {
      if (grid[i][j] % 2 == 1) {
        grid[i][j]--;
        grid[i][j+1]++;
        ans.pb(ORD{j, i, j+1, i});
      }
    }
  }

  rep(i, 0, H-1) {
    if (grid[i][W-1] % 2 == 1) {
      grid[i][W-1]--;
      grid[i+1][W-1]++;
      ans.pb(ORD{W-1, i, W-1, i+1});
    }
  }

  if (ans.empty()) {
    cout << 0 << endl;
    return 0;
  }

  cout << (int)ans.size() << endl;
  for (auto ord: ans) {
    cout << ord.y1+1 << " " << ord.x1+1 << " " << ord.y2+1 << " " << ord.x2+1 << endl;
  }

  return 0;
};


Measured memory_bytes: 5360
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<string> s;
  for(int i = 0; i < h; i++){
    string st;
    cin >> st;
    s.pb(st);
  }
  for(int i = 0; i < h; i++){
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	string n; cin >> n;
	string a = n.substr(0,3);
	cout << a << endl;
}

Measured memory_bytes: 3564
#include <iostream>
void swap(int A[],int B[],int i,int j)
{
    int temp;
    temp=A[i];
    A[i]=A[j];
    A[j]=temp;
    temp=B[i];
    B[i]=B[j];
    B[j]=temp;
}

void pushdown(int A[],int B[],int f,int l)
{
    int p=f;
    int c=2*p;
    while (c<=l)
    {
        if(c<l&&((B[c-1]<B[c])||(B[c-1]==B[c]&&A[c-1]<A[c])))c++;
        if(B[c-1]<B[p-1]||(B[c-1]==B[p-1]&&A[c-1]<A[p-1]))break;
        swap(A,B,c-1,p-1);
        p=c;
        c=2*p;
    }
}

void heap_sort(int A[],int B[],int n)
{
    int i;
    for(i=n/2;i>0;i--)pushdown(A,B,i,n);
    for(i=n;i>1;i--)
    {
        swap(A,B,0,i-1);
        pushdown(A,B,1,i-1);
    }
}
int main()
{
    int N;
    int i;
    int t=0;
    scanf("%d",&N);
    int A[N],B[N];
    for(i=0;i<N;i++)scanf("%d %d",&A[i],&B[i]);
    heap_sort(A,B,N);
    for(i=0;i<N;i++)
    {
        t+=A[i];
        if(t>B[i])
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1792
/*解説AC*/

#include<bits/stdc++.h>
using namespace  std;
using Int = long long;
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
int main(){
    Int N;  cin >> N;
    using tup = tuple<Int,Int,Int,Int>;
    constexpr Int inf = -1 * (1LL << 60);
    vector<tup>input;
    for(int i = 0; i < N; ++i){
        int w,s,v; cin >> w >> s >> v;
        input.emplace_back(w + s, w,s,v);
    }
    // 優先順位を決めて、並び替える
    sort(input.begin(),input.end());
    // dp[i][j] := i番目のblockを使ったとき, weight のときの max_value
    
    vector<vector<Int>>dp(N + 1, vector<Int>(10000 * 3,inf));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i){
        Int w,s,v,g; tie(g,w,s,v) = input[i];
        for(int j = 0; j < dp[i].size(); ++j){
            if(dp[i][j] == inf) continue;
            cmax(dp[i + 1][j],dp[i][j]);
            if(s >= j){
                cmax(dp[i + 1][j + w], dp[i][j]  + v);
            }
        }
    }
    cout << *max_element(dp.back().begin(), dp.back().end()) << endl;
}


Measured memory_bytes: 236800
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	
		//BufferedReader br=new BufferedReader(new FileReader("sample.txt"));
		String str=br.readLine();
		String[] st=str.split(" ");
		str=br.readLine();
		Dice dice1 =new Dice(st);
		dice1.roll(str);
		System.out.println(dice1.getd1());
	}
	}
class Dice{

String top,front,right,left,back,bot;

	Dice(String[] s){
		top=s[0];
		front=s[1];
		right=s[2];
		left=s[3];
		back=s[4];
		bot=s[5];
	}
		
	void roll(String s){
		String top,bot,back,front,left,right;
		for(int i=0;i<s.length();i++){
			char c=s.charAt(i);
		top=this.top;
		bot=this.bot;
		front=this.front;
		back=this.back;
		left=this.left;
		right=this.right;
		
		switch(c){
		case 'N':
			top=this.front;
			bot=this.back;
			front=this.bot;
			back=this.top;
			break;
		
		case 'S':
			top=this.back;
			bot=this.front;
			front=this.top;
			back=this.bot;
			break;
		case 'W':
			top=this.right;
			bot=this.left;
			right=this.bot;
			left=this.top;break;
		
		case 'E':
			top=this.left;
			bot=this.right;
			right=this.top;
			left=this.bot;
			break;
		}
		this.top=top;
		this.front=front;
		this.right=right;
		this.left=left;
		this.back=back;
		this.bot=bot;
		
	}}
	String getd1(){return this.top;}}

Measured memory_bytes: 17068
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::vector<int>e(12);
	rep(i, 12) in >> e[i];
	std::sort(e.begin(), e.end());
	bool f1 = e[0] == e[1] && e[1] == e[2] && e[2] == e[3];
	bool f2 = e[4] == e[5] && e[5] == e[6] && e[6] == e[7];
	bool f3 = e[8] == e[9] && e[9] == e[10] && e[10] == e[11];
	if (f1&&f2&&f3) out << "yes" << std::endl;
	else out << "no" << std::endl;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int M; cin >> M;
    ll K; cin >> K;
    if(K == 0){
        int cnt = 0;
        int loop = pow(2, M+1);
        rep(i, loop){
            if(i == loop-1) cout << cnt << endl;
            else cout << cnt << " ";
            if(i % 2 == 1) cnt++;
        }
    }
    else if(K <= pow(2, M)-1){
        if(M == 1){
            cout << -1 << endl;
            return 0;
        }
        cout << 0 << " " << K << " ";
        int mx = pow(2, M)-1;
        if(K < mx){
            rep(i, K) cout << i << " ";
            for(int i = K+1; i <= mx; i++) cout << i << " ";
            cout << K << " ";
            for(int i = mx; i >= K+1; i--) cout << i << " ";
            for(int i = K-1; i >= 1; i--){
                if(i == 1) cout << i << endl;
                else cout << i << " ";
            }
        }
        else{
            rep(i, K) cout << i << " ";
            for(int i = K; i >= 1; i--){
                if(i == 1) cout << 1 << endl;
                else cout << i << " ";
            }
        }
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  int D,N;
  cin >> D >> N;
  int bai = 1;
  for(int i = 0; D > i; i++){
    bai *= 100;
  }
  if(N == 100){
    cout << N * bai + bai << endl;
  }else{
    cout << N * bai << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var c = cin.nextInt();

            if (a == b) Console.WriteLine(c);
            if (a == c) Console.WriteLine(b);
            if (b == c) Console.WriteLine(a);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayString(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = next();
            }
            return Array;
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            KeyValuePair<int, int> res = ExtendedEuclid(a, b);
            Console.WriteLine(res.Key + " " + res.Value);
        }

        static KeyValuePair<int, int> ExtendedEuclid(int a, int b)
        {
            int r0 = a, r1 = b;
            int x0 = 1, x1 = 0;
            int y0 = 0, y1 = 1;

            while (r1 > 0)
            {
                int q = r0 / r1;
                int r2 = r0 % r1;
                int x2 = x0 - q * x1;
                int y2 = y0 - q * y1;

                r0 = r1; r1 = r2;
                x0 = x1; x1 = x2;
                y0 = y1; y1 = y2;
            }
            return new KeyValuePair<int, int>(x0, y0);
        }
    }
}

Measured memory_bytes: 9240
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
public class B{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        HashSet<int> p = new HashSet<int>();
        List<int> a = new List<int>();
        for (int i = 0;i<n;i++){
            int ai = int.Parse(Console.ReadLine());
            ai--;
            a.Add(ai);
        }
        int ans = 0;
        int now = 0;
        while (now != 1){
            ans++;
            p.Add(now);
            now = a[now];
            if (p.Contains(now)){
                Console.WriteLine(-1);
                Environment.Exit(0);
            }
        }
        
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 18656
#include<stdio.h>
int main(void){
    int a,b,c,min,sum;
    int i;

    sum=0; min=100;
    for(i=0;i<4;i++){
	scanf("%d",&a);
	sum+=a;
	if(a<min) min=a;
    }

    scanf("%d%d",&b,&c);
    if(b>c) printf("%d\n",sum-min+b);
    else printf("%d\n",sum-min+c);

    return 0;
}

Measured memory_bytes: 600
#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 loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll INF = 1ll<<60;

int main(){
    ll n, m; cin >> n >> m;
    vector<ll> dp(1ll<<n,INF); dp[0] = 0;
    rep(i,m){
        ll a, b; cin >> a >> b;
        ll count = 0;
        rep(i,b){
            ll c; cin >> c; c--;
            count |= 1<<c;
        }
        rrep(j,1ll<<n) chmin(dp[j|count],dp[j]+a);
    }
    if(dp[(1ll<<n)-1] == INF) cout << -1 << endl;
    else cout << dp[(1ll<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 3652
N=int(input())
S=input()
B=[]
W=[]
i=0
while i<N:
    if S[i]=='#':
        B.append(i)
    else:
        W.append(i)
    i+=1

X=len(B)
Y=len(W)
ans=0
i=j=0
while i<X and j<Y:
    if B[i]<W[j]:
        i+=1
        j+=1
        ans+=1
    else:
        j+=1
print(ans)

Measured memory_bytes: 17288
#include <stdio.h>
 
int i,num;
int main()
{
  int a[251];
  scanf("%d",&num);
  for(i=1;i<=num;i++)
    scanf("%d",&a[i]);
for(i=1;i<=num;i++){
    printf("node %d: key = %d, ",i,a[i]);
    if(i!=1)
      printf("parent key = %d, ",a[i/2]);
    if(2*i<=num)
      printf("left key = %d, ",a[2*i]);
if(2*i+1<=num)
      printf("right key = %d, ",a[2*i+1]);
 printf("\n");
 
 
}
  return 0;
}

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

using namespace std;
int TB[10][10];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 1, tmp = 1; i <= N; ++i) {
        if (i == tmp*10) tmp *= 10;
        int t = i/tmp, b = i%10;
        ++TB[t][b];
    }
    long long ans = 0;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            ans += TB[i][j]*TB[j][i];
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int a = ni();
		int b = ni();
		if(a < 10 && b < 10) {
			System.out.println(a*b);
		}else {
			System.out.println(-1);
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
#include <stdio.h>

int main()
{
	int n,k;
	scanf("%d %d", &n, &k);
	getchar();
	char s[n];
	scanf("%s", s);
	for ( int i = 0; i < n; i++ ) {
		if ( i + 1 != k ) printf("%c", s[i]);
		else {
			if ( s[i] == 'A' ) printf("a");
			else if ( s[i] == 'B' ) printf("b");
			else printf("c");
		}
	}
	printf("\n");
  	return 0;
}

Measured memory_bytes: 128
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rept(i,s,n) for (int i = (s); i < (n); ++i)

#include <iostream>
#include <cmath>
#include <bitset>
using namespace std;

int main() {

  string s = "125";

  cin >> s;
  long bit;
  long tmp;
  long ans = 0;

  for(bit=0; bit < 1<<(s.length()-1); ++bit ){
    tmp = s.at(0)-'0';

    for(int digit=0; digit<s.length()-1; ++digit){
      if(bit & 1<<digit){
        ans += tmp;
        tmp = 0;
      }
      tmp = tmp*10 + s.at(digit+1)-'0';
    }
    ans += tmp;

  }


  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
交換時間と移動時間
wf?bfs?
せいぜい50個の町だから、かなり探索する
交換をどうするか
ルートきめて、最短をマッピング
DFSになるか。

交換時間の割り振り難しいな
交換のためにもどるのもあるのか･･･。
頂点と銀貨数でDPか
毎回、50*50=2500枚までDPか
2550*50か
往復とか寄り道の場合･･･考慮しなくても間に合うかな

1-2-3-4-5-6 
-7-8

1-6-1-8とか。
50*50*50*50

1-2-3
DP[1][1]=1で1銀交換時間
あれ、2500^2になってるかな
2回戻ることはさすがにないかな
出発はいつも１

2500まで交換
移動先のDP値より、小さければqueに入れる
ここがいけてないんだが
移動先での交換レートが低かった場合、50個いれては交換50回しなおしを2500通りやる？
いやいや、minとっていけば2500でおわる。鈍いな。

queue {1,2}
1->2
bool move=falseとか
DP[2][j]=min(DP[1][j+銀貨]+移動時間,)

queueには候補地だけでいいかな

WA1個とか、一番きついやつ
*/

struct X{
  ll to,ag,mo;
};
ll N,M,S,oo=1e18;
vector<vector<X>> G(55,vector<X>(0,{0,0,0}));
vector<vector<ll>>DP(55,vector<ll>(2650,oo));
vector<ll> C(55,0),D(55,0),ans(55,oo);
vector<bool> used(55,false);
queue<ll> Q;
int main(){
  cin>>N>>M>>S;
  S=min(S,2600LL);
  DP[1][S]=0;
  for(ll i=1; i<=M; i++){
    ll to1,to2,ag,mo; cin>>to1>>to2>>ag>>mo;
    G[to1].push_back({to2,ag,mo});
    G[to2].push_back({to1,ag,mo});
  }
  for(ll i=1; i<=N; i++) cin>>C[i]>>D[i];
   Q.push(1);
  //DP処理、毎回2500枚まで交換。上書きもしてく？
  //移動,2500通りコピー
  while(!Q.empty()){
    //まず、その町で2500枚まで交換
    ll now=Q.front(); Q.pop();
    for(ll j=0; j<=2600; j++){
      ll n=min(j+C[now],2600LL);//1交換
      DP[now][n]=min(DP[now][n],DP[now][j]+D[now]);
    }
    //移動して効率いいなら移動。そうじゃないならいかない
    for(auto v:G[now]){
      bool move=false;
      for(ll i=v.ag; i<=2600; i++){//運賃
        ll pre=DP[now][i];
        if(pre==oo) continue;
        ll to_dp=DP[v.to][i-v.ag];
        ll next_dp=pre+v.mo;
        if(to_dp<=next_dp) continue;
        move=true;//now->v.toに動くの確定 
        //2の町で10枚持ってる状態が10分。
        //1の町で15枚もってて、5枚はらって2の町にいくと、9分だったら、2の町に行くの確定。11分だったらいかない。
        DP[v.to][i-v.ag]=next_dp;
      }
      if(move) Q.push(v.to);
    }
  }
  //ansつくる 
  for(ll i=2; i<=N; i++) for(ll j=0; j<=2600; j++) ans[i]=min(ans[i],DP[i][j]);
  for(ll i=2; i<=N; i++) cout<<ans[i]<<endl;  
}

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

int main(void){
  int num[10];
  while(cin>>num[9],num[9]){
    for(int i = 0 ; i < 9 ; i ++){
      cin>>num[i];
      num[9]-=num[i];
    }
    cout<<num[9]<<endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;

int main(void)
{
    int A,B,K;
    cin >> A >> B >> K;
    
    int a = max(A,B);
    int b = min(A,B);
    int count = 0;
    for(int i = b; i > 0; i--) {
        if (a%i == 0 && b%i == 0) {
            count++;
            if (count == K ){
                cout << i << endl;
                return 0;
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  long long int n;
  while(cin>>n,n){
    long long int co=0;
    while(n!=1){
      co++;
      if(n%2)n=3*n+1;
      else n/=2;
    }
    cout<<co<<endl;
  }
}

Measured memory_bytes: 1160
#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()
typedef long long ll;

int a,b;

int main() {
  cin >> a >> b;
  if(a+b==3)
  cout << 3 << endl;
  else if(a+b==4)
  cout << 2 << endl;
  else 
  cout << 1 << endl;
}

Measured memory_bytes: 256
import collections
N = int(input())
inp = list(map(int,input().split()))
dic = dict(collections.Counter(inp))
wa = 0
for i, j in dic.items():
	wa += i * j
se = set(dic.keys())
for i in range(int(input())):
	a, b = map(int,input().split())
	if a in se:
		wa += dic[a] * (b-a)
		if b in se:
			pass
		else:
			dic[b] = 0
		se.add(b)
		dic[b] += dic[a]
		dic[a] = 0
	print(wa)

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int g[min(a, b)] = {};
  int index = 0;
  for (int i = 1; i <= min(a, b); i++) {
    if (a % i == 0 && b % i == 0) {
      g[index++] = i;
    }
  }
  cout << g[index - k] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val Array(n, k) = input.nextLine().split(" ").map(_.toInt)
      val ns          = 1.to(n).toArray.map(_ => input.nextLine().toInt).sorted
      println(
        0.to(n - k)
          .map { i =>
            Math.abs(ns(i) - ns(i + k-1))
          }
          .min
      )
    }

  }

}


Measured memory_bytes: 109284
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int n, m;
vector<PII> _array;

int main() {
	while ( ~scanf( "%d %d", &n, &m ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d %d", &_array[ i ].second, &_array[ i ].first );
		}
		sort( _array.rbegin(), _array.rend() );
		for ( int i = 0; i < n; i++ ) {
			if ( m == 0 ) {
				break;
			}
			int use_m = min( m, _array[ i ].second );
			_array[ i ].second -= use_m;
			m -= use_m;
		}
		int ans = 0;
		for ( int i = 0; i < n; i++ ) {
			ans += _array[ i ].first * _array[ i ].second;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1320
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

struct edge {
	int u, v, cost;
};

const int MAX_N = 100;
const int MAX_E = 100*99/2;
int par[MAX_N];
int rank[MAX_N];
edge es[MAX_E];

int V, E;	//  頂点数と辺数

// n要素で初期化
int init_union_find (int n )
{
	rep (i, n ){
		par[i] = i;
		rank[i] = 0;
	} // end for
}

// 木の根を求める
int find (int x )
{
	if (par[x] == x )
		return x;

	// 親を遡る
	return par[x] = find (par[x] );
}

// xとyの属する集合をマージ
void unite (int x, int y )
{
	x = find (x);
	y = find (y);

	// 親が一緒なら何もしない
	if (x == y )
		return;

	// ランクが小さい方の木をぶら下げる
	if (rank[x] < rank[y] ){
		// x を y にぶら下げる
		par[x] = y;
	}else{
		// ランクが同じか rank[x] > rank[y]
		par[y] = x;
		if (rank[x] == rank[y] )
			rank[x]++;
	} // end if
}

// xとyが同じ集合に属するか否か
bool same (int x, int y )
{
	return (find (x) == find (y) );
}

bool comp (const edge& e1, const edge& e2 )
{
	return e1.cost < e2.cost;
}

int kruskal (void )
{
	sort (es, es + E, comp );
	init_union_find (V );
	int res = 0;
	rep (i, E ){
		edge e = es[i];
		if (!same (e.u, e.v ) ){
			unite (e.u, e.v );
			res += e.cost;
		} // end if
	} // end rep

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.carden_lentern", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		int m;
		scanf ("%d", &m );
		rep (i, m ){
			int from, to, cost;
			scanf ("%d,%d,%d", &from, &to, &cost );
			es[i].u = from; es[i].v = to; es[i].cost = cost; 
		} // end rep
		E = m;
		V = n;
		int ans = kruskal();	// 最小全域木の経路の長さ
		int res = ans/100 - (V-1);
		printf ("%d\n", res );
	} // end loop

	return 0;
}

Measured memory_bytes: 1264
#include<stdio.h>
int a[1000];
int main(){
	int i;
	int sum=1,k=1,n;
	scanf("%d",&n);
	for (i=1;i<=n;i++) {
		k=k*3;
		scanf("%d",&a[i]);
		if (a[i]%2==0) sum=sum*2; 
	}
	printf("%d\n",k-sum);
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
vec S,ans;
int n;
void solve(){
    vector<int> Z(S.size());
    Z[0]=S.size();
    int i=1,j=0;
    while(i<S.size()){
        while(i+j<S.size()&&S[j]==S[i+j]) j++;
        Z[i]=j;
        if(j==0){
            i++;
            continue;
        }
        int k=1;
        while(k<j&&k+Z[k]<j){
            Z[i+k]=Z[k];
            k++;
        }
        i+=k;
        j-=k;
    }
    rep(i,Z.size()){
        if(i>=n&&i<2*n&&Z[i]>=n) ans.push_back(i-n);
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vec a(n),b(n),A(n),B(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) A[i]=a[i]^a[(i+1)%n],B[i]=b[i]^b[(i+1)%n];
    rep(i,n) S.push_back(B[i]);
    rep(j,2)rep(i,n) S.push_back(A[i]);
    solve();
    for(auto i:ans){
        cout<<i<<" "<<(b[0]^a[i])<<"\n";
    }
}

Measured memory_bytes: 20584
#include<stdio.h>
int main()
{
	int n,i,j;
	scanf("%d",&n);
	long int b[n]={0};
	long int a[n]={0};
	for(i=0;i<n;i++)
	{
		scanf("%ld",&a[i]);
	}
		for(i=n-1,j=0;i>=0;i=i-2,j++)
		{
			b[j]=a[i];
			if(i!=0)
			b[n-j-1]=a[i-1];
		}
		for(i=0;i<n;i++)
		{
			printf("%ld ",b[i]);
		}
		return 0;
 } 

Measured memory_bytes: 5248
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
	 ios::sync_with_stdio(false);
	 int A, B;
	 while(cin>>A>>B)
	 {
	 	 if(A*B%2==0) cout<<"No\n";
	 	 else cout<<"Yes\n";
	 }
	 return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=[int(w) for w in input().split()]
x=[0]*(n)
for i in range(m):
    a,b=map(int,input().split())
    
    x[a-1]=max(h[b-1],x[a-1])
    x[b-1]=max(h[a-1],x[b-1])
        
ans=0
for i in range(n):
    if (h[i]>x[i]) or x[i]==0:
        ans+=1
print(ans)

Measured memory_bytes: 20120
#include <stdio.h>
#define MAX 500001
int A[MAX];
void maxHeapify(int,int);
  int main(){
    int i,n;
    for(i = 0;i<MAX;i++){
      A[i]=0;
    }
    scanf("%d",&n);
    for(i=1;i<=n;i++){
      scanf("%d",&A[i]);
    }

    for(i = n/2 ;i>=1;i--){
         maxHeapify(i,n);
    }
    for(i = 1 ;i<=n;i++){
      if(i ==n){
	printf(" %d\n",A[i]);
      }
      else  printf(" %d",A[i]);
   
    }
    return 0;
  }
  void maxHeapify(int i,int n){
  int l,r,leargest=0,tmp=0;
  l = 2*i;
  r  = (2*i)+1;
  if(l<=n && A[l]>A[i]){
    leargest =l;
  }
  else leargest = i;
  if(r<=n && A[r] >A[leargest])
    {
      leargest = r;
    }
  if(leargest !=i){
    tmp =  A[i];
    A[i] = A[leargest];
    A[leargest] = tmp;
  maxHeapify(leargest,n);
  }
}



Measured memory_bytes: 3808
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#define INT long long int
#define MOD 1000000007
#define oo 987654321
using namespace std;
int n, m, k, a[10001], p = 1, b[110][110];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    for(int i = 1 ; i <= k ; i++ ) cin>>a[i];
    for(int i = 0 ; i < n ; i++ )
    {
        if( i%2 == 0 )
        {
            for(int j = 0 ; j < m ; j++ )
            {
                while( !a[p] ) p++;
                b[i][j] = p;
                a[p]--;
            }
        }
        else
        {
            for(int j = m-1 ; j >= 0 ; j-- )
            {
                while( !a[p] ) p++;
                b[i][j] = p;
                a[p]--;
            }
        }
    }
    for(int i = 0 ; i < n ; i++, cout<<endl ) for(int j = 0 ; j < m ; j++ ) cout<<b[i][j]<<" ";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 100000 + 10;
typedef long long LL;

int n, m, deg[N];
LL ans = 0;
int col[N];

vector<int> g[N];


int gg = 0;
void dfs(int u) {
    for (auto v: g[u]) {
        if (col[v]) {
            if (col[u] + col[v] != 3) {
                gg = 1; 
            } 
        } else {
            col[v] = 3 - col[u];
            dfs(v);
        }
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i ++) {
        int u, v; scanf("%d%d", &u, &v);
        deg[u] ++, deg[v] ++;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    LL A = 0, B = 0, C = 0;
    for (int i = 1; i <= n; i ++) {
        if (deg[i] == 0) {
            C ++;
            continue;
        }
        if (col[i] == 0) {
            col[i] = 1; 
            gg = 0;
            dfs(i);
            if (gg) A ++;
            else B ++; 
        }
    }
    // printf("A = %d, B = %d, C = %d\n", A, B, C);
    ans = ans + C * n * 2 - C * C;
    ans = ans + A * B + B * A;
    ans = ans + A * A + B * B * 2;
    printf("%lld\n", ans);
}   




Measured memory_bytes: 10368
#include <bits/stdc++.h>
// clang-format off
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
#define gcn(N) int N;cin >> N;
#define debug(var) do {std::cout << #var << " : "; view(var);} while (0)
template <typename T> void view(T e) { std::cout << e << std::endl; }
template <typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template <typename T> void view(const std::vector<std::vector<T>>& vv) { for (const auto& v : vv) { view(v); } }
using namespace std;
void before_main() { std::cout << std::fixed << std::setprecision(10); } namespace { struct before_main_caller { before_main_caller() { before_main(); } } caller; }
// clang-format on
signed main()
{
    double a, b, x;
    cin >> a >> b >> x;
    double l = 2 * b - 2 * x / (a * a);
    if (l < b) {
        cout << (atan2(l, a) / M_PI) * 180 << endl;
    } else {
        double k = 2 * x / (a * b);
        cout << 90 - (atan2(k, b) / M_PI) * 180 << endl;
    }
}


Measured memory_bytes: 384
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                var v = double.Parse(line);
                var f = Math.Pow(v / 9.8, 2) * 4.9 / 5 + 1;
                Console.WriteLine((int)f+1);
            }
        }
      
    }
}



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

int main() {
	int n, m;
	int sum = 0;
	
	cin >> n >> m;

	int a[n][m], b[m];

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < m; i++){
		cin >> b[i];
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
		sum = 0;
	}

	return 0;
}


Measured memory_bytes: 3108
from collections import deque
S=input()
Q=int(input())
r_count=0
top=[1,2]
tail=[2,1]
S=deque(list(S))

for i in range(Q):
    q=list(input().split())
    if q[0]=="1":
        r_count+=1
    else:
        q[1]=int(q[1])
        if q[1]==1:
            q[1]=top[r_count%2]
        else:
            q[1]=tail[r_count%2]
        
        if q[1]==1:
            S.appendleft(q[2])
        else:
            S.append(q[2])
S=list(S)
if r_count%2==1:
    S.reverse()
print(''.join(S))

Measured memory_bytes: 8420
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long n, k;
  cin >> n >> k;
  int ans = 0;
  fore(i, 0, n) {
    Long a, b;
    cin >> a >> b;
    Long d = a * a + b * b;
    if (d <= k * k) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
n = int(input())
p = list(map(int,input().split()))
i = 1
ans = 0
while i <= n-2:
  if (p[i]-p[i-1])*(p[i]-p[i+1]) < 0:
    ans += 1
  if (p[i]-p[i-1])*(p[i]-p[i+1]) == 0:
    if p[i] < p[i-1] or p[i] < p[i+1]:
      ans += 1
  i += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 1e6 + 10;
int power(int a, int b) {
	int rtr = 1;
	for (; b > 0; b /= 2, a = 1ll * a * a % mod)
		if (b & 1)
			rtr = 1ll * rtr * a % mod;
	return rtr;
}
int n, m, ans, fc[N], ifc[N];
void Pre() {
	fc[0] = ifc[0] = 1;
	for (int i = 1; i < N - 5; i++) 
		fc[i] = 1ll * fc[i - 1] * i % mod, ifc[i] = power(fc[i], mod - 2);
	return;
}
int ch(int x, int y) {
	if (x > y)
		return 0;
	return 1ll * fc[y] * ifc[x] % mod * ifc[y - x] % mod;
}
int main() {
	ios_base::sync_with_stdio (false), cin.tie(0), cout.tie(0);
	Pre();
	cin >> n >> m;
	ans = max(n, m);
	for (int i = 1; i <= min(n, m); i++) {
		int nd = 1ll * ch(i, 2 * i) * ch(n - i, n + m - 2 * i) % mod, all = power(ch(n, n + m) * 2 % mod, mod - 2);
		ans = (ans + 1ll * nd * all % mod) % mod;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 11460
n = int(input())
h = [int(i) for i in input().split()]

cnt = max = 0
for i in range(0, n-1):
    if h[i+1] <= h[i]:
        cnt += 1
    else:
        if cnt > max:
            max = cnt
        cnt = 0
else:
    if cnt > max:
        max = cnt

print(max)


Measured memory_bytes: 14252
S = input()
nN = 0
nW = 0
nS = 0
nE = 0
for c in S:
  if c == "N":
    nN += 1
  if c == "W":
    nW += 1
  if c == "S":
    nS += 1
  if c == "E":
    nE += 1
if (nN > 0 and nS == 0) or (nS > 0 and nN == 0) or (nW > 0 and nE == 0) or (nE > 0 and nW == 0):
  print("No")
else:
  print("Yes")


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;
const double PI = acos(-1.0);

double DEG_to_RAD(double d) { return d * PI / 180.0; }

int main(){
  //  freopen("test.txt","r",stdin);
    int a,b;
    cin >> a >> b;
    cout << ceil(double(a+b)/2) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		A = A*N;
		if(A>=B) {
			System.out.println(B);
		}else {
			System.out.println(A);
		}
	}

}


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

int main() {
    long long 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: 3636
import heapq

x, y, z, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

n = []
heapq.heapify(n)
heapq.heappush(n, (-(a[0]+b[0] + c[0]), 0,0,0))
for i in range(K):
    (m, j, k, l) = heapq.heappop(n)
    print(-m)
    if j + 1 <=x-1:
        s = (-(a[j+1]+b[k]+c[l]), j+1, k, l)
        if s not in n:
            heapq.heappush(n ,s)

    if k + 1 <=y-1:
        s = (-(a[j]+b[k+1]+c[l]), j, k+1, l)
        if s not in n:
            heapq.heappush(n ,s)
    
    if l+ 1 <=z-1:
        s = (-(a[j]+b[k]+c[l+1]), j, k, l+1)
        if s not in n:
            heapq.heappush(n ,s)

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    long long x;
    cin >> x;
    long long turn = 2 * (x / 11);
    x %= 11;
    if (x > 6) turn += 2;
    else if (x > 0) ++turn;
    cout << turn << endl;
}

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

using namespace std;
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define FO(i, x, n) for(int i=x; i<n; i++)
#define aLL(x) x.begin(), x.end()
#define pB push_back
#define eB emplace_back
#define tRav(a, x) for(auto& a: x)
#define fI first
#define sE second
#define lB lower_bound
#define uB upper_bound
#define MOD 1000000007


int main(){
	fast_cin();
	int n;cin>>n;
	cout<<(n+1)/2<<endl;
}


Measured memory_bytes: 256
n = list(map(int,list(input())))
a = []

for i, code in enumerate(n):
    if code == 1:
        code = 9
        
    elif code == 9:
        code = 1

    a = a + [code]
    
a = list(map(str,a))
b = "".join(a)
print(b)


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

int N = 210000 - 1; // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
long long int B1[210000], B2[210000];

void add(int a, long long int w, long long int BIT[]){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

long long int sum(int a, long long int BIT[]){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(long long int BIT[]){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	init(B1);
	init(B2);
	
	for(int i = 0; i < q; i++){
		long long int num, a, b, c;
		cin >> num;
		if(num == 0){
			cin >> a >> b >> c;
			add(a, c, B1);
			add(b + 1, -c, B1);
			add(a, -(a - 1) * c, B2);
			add(b + 1, b * c, B2);
			/*
			for(int j = 1; j <= n; j++){
				cout << sum(j, B1) << " ";
			}
			cout << endl;
			for(int j = 1; j <= n; j++){
				cout << sum(j, B2) << " ";
			}
			cout << endl;
			for(int j = 0; j < n; j++){
				long long int num1 = sum(j, B1) * j + sum(j, B2);
				long long int num2 = sum(j + 1, B1) * (j + 1) + sum(j + 1, B2);
				cout << num2 - num1 << " ";
			}
			cout << endl;
			*/
		}else{
			cin >> a >> b;
			a--;
			long long int num1 = sum(a, B1) * a + sum(a, B2);
			long long int num2 = sum(b, B1) * b + sum(b, B2);
			cout << num2 - num1 << endl;
		}
	}
	
	return 0;
}


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

int main()
{
    
int A,B;
cin >> A >> B ;

if (A>=13){
cout << B << endl;    
}

else if  (6<= A && A<=12) {
cout << B/2 << endl;      
}
else{
cout << 0 << endl; 
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,f[3][N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=2;++i)
		for (int j=1;j<=n;++j){
			scanf("%d",&f[i][j]);
			f[i][j]+=max(f[i-1][j],f[i][j-1]);
		}
	printf("%d",f[2][n]);
	return 0;
}


Measured memory_bytes: 256