akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n, m, p, a, b;

void solve(){
    int t[n];
    rep(i, n) scanf("%d", &t[i]);
    vector<pii> G[m];
    rep(i, p){
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        --x; --y;
        G[x].emplace_back(y, z);
        G[y].emplace_back(x, z);
    }

    double d[m][1<<n];
    rep(i, m)rep(j, 1<<n) d[i][j] = INF;
    using state = pair<double, pii>;
    priority_queue<state, vector<state>, greater<>> que;
    d[a][0] = 0;
    que.push({0, {a, 0}});
    while(!que.empty()){
        auto s = que.top();
        que.pop();
        double dist = s.fi;
        int v = s.se.fi, S = s.se.se;
        if(dist > d[v][S]) continue;
        for(auto &e: G[v]){
            rep(i, n)if(!((S>>i) & 1)){
                int T = S | (1<<i);
                if(chmin(d[e.fi][T], dist + (double)e.se / t[i])){
                    que.push({d[e.fi][T], {e.fi, T}});
                }
            }
        }
    }
    double ans = INF;
    rep(i, 1<<n) chmin(ans, d[b][i]);
    if(ans < mod) printf("%.10lf\n", ans);
    else puts("Impossible");
}

int main(){
    while(scanf("%d%d%d%d%d", &n, &m, &p, &a, &b) && n){
        --a; --b;
        solve();
    }
}


Measured memory_bytes: 4480
#cmb
mod=10**9+7
MAX=10**6

g1=[1,1]
g2=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(pow(num_1,mod-2,mod))
    
def cmb(n,r,MOD):
    return g1[n]*g2[r]*g2[n-r]%MOD

x,y=map(int,input().split())
ans=0
for k in range(y//2+1):
    l=y-2*k
    if l>=0 and k+2*l==x:
        ans=(ans+cmb(k+l,k,mod))%mod
print(ans)

Measured memory_bytes: 108664
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int* x = new int[N+1];
  x[0] = X;
  for(int i = 1; i < N + 1; i++){
    cin >> x[i];  
    
  }
  int* y = new int[M+1];
  y[0] = Y;
  for(int i = 1; i < M + 1; i++){
    cin >> y[i];
    
  }
  sort(x, x + N + 1);
  sort(y, y + M + 1);
  
  if(y[0] <= x[N]){
    cout << "War" << endl;
    return 0;
    
  }
  cout << "No War" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define NUM 0
#define NOT 1
#define AND 2
#define OR  3
#define PAREN 4

int cheak(string t){//cout<<t<<endl;
	stack<pair<int,int> > sta;
	
	for(int i = 0; i < t.size(); i++){
		if('0' <= t[i] && t[i] <= '2'){
			int num = t[i]-'0';
			for(; !sta.empty();){
				if(sta.top().first == NOT){
					sta.pop();
					num = 2-num;
					
				} else break;
			}
			sta.push(make_pair(NUM,num));
				
		} else if(t[i] == ')'){
			pair<int,int> a = sta.top(); sta.pop();
			pair<int,int> b = sta.top(); sta.pop();
			pair<int,int> c = sta.top(); sta.pop();sta.pop();
			if(b.first == AND){
				a.second = min(a.second,c.second);
			} else if(b.first == OR){
				a.second = max(a.second,c.second);
			}
			int num = a.second;
			//cout<<"num = "<<num<<" "<<sta.top().first<<endl;
			for(; !sta.empty();){
				if(sta.top().first == NOT){
					sta.pop();
					num = 2-num;
					
				} else break;
			}
			sta.push(make_pair(NUM,num));	
		} else if(t[i] == '-'){
			sta.push(make_pair(NOT,0));
		} else if(t[i] == '*'){
			sta.push(make_pair(AND,0));
		} else if(t[i] == '+'){
			sta.push(make_pair(OR,0));
		} else if(t[i] == '('){
		  	sta.push(make_pair(PAREN,0));
		}
		//cout<<i<<endl;if(!sta.empty())cout<<i<<" "<<sta.top().first<<" "<<sta.top().second<<endl;
	}
	return sta.top().second;
}
bool solve(){
  string s;
  cin>>s;//cout<<cheak(s)<<endl;return false;

	if(s == ".") return false;
	
	int count = 0;
	string temp = s;
	for(int i = 0; i < 27; i++){
		int p = i%3, q = (i/3)%3, r = (i/9)%3;
		for(int j = 0; j < s.size(); j++){
			if(s[j] == 'P'){
				temp[j] = '0' + p;
			} else if(s[j] == 'Q'){
				temp[j] = '0' + q;
			} else if(s[j] == 'R'){
				temp[j] = '0' + r;
			}
		}
		if(cheak(temp) == 2)count++;
	}
	
	cout<<count<<endl;
	return true;
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	while(solve());
	
	
	return 0;
}



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

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

  if (K % 2 == 0 || K % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int ans = 1;
  int seven = 7 % K;
  while (seven != 0) {
    seven = (seven * 10 + 7) % K;
    ++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<unordered_set<ll>> net(n);
    for(int i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        net.at(a).insert(b);
        net.at(b).insert(a);
    }

    vector<ll> v(n);
    for(int i = 0; i < n; ++i){
        v.at(i) = i;
    }

    ll ans = 0;
    do{
        bool flag = true;
        for(int i = 0; i < n - 1; ++i){
            if(net.at(v.at(i)).count(v.at(i + 1)) == 0){
                flag = false;
                continue;
            }
        }
        ans += flag;
    }while(next_permutation(v.begin() + 1, v.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#define M 2000000000
using namespace std;
int main(void)
{
    int n,i,j,sum,p[5000],a[5000],mn;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&p[i]);
	mn=M;
	for(i=0;i<=p[0];i++){
	    for(j=0;j<n;j++) a[j]=p[j];
		a[0]=a[0]-i;
		sum=i;
		for(j=0;j<n-1;j++){
		    if(a[j]>0){
			    a[j+1]-=a[j];
				sum+=a[j]*2;
				a[j]=0;
			}
		}
		if(a[n-1]>0) sum+=a[n-1];
		mn=min(mn,sum);
	}
	printf("%d\n",mn);
	return 0;
}

Measured memory_bytes: 2760
import java.util.Scanner;

class Main {
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int a, b ;
	a = scan.nextInt();
	b = scan.nextInt();
	
	if (a < b){
		System.out.println("a < b");
	}else if (a > b){
		System.out.println("a > b");
	}else if (a == b){
		System.out.println("a == b");
	}
		
	}
}

Measured memory_bytes: 26208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> adj[n+1];
    for(int i=2;i<=n;i++)
    {
        int v=2;
        int parent;
        cin>>parent;
        adj[parent].push_back(i);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<adj[i].size()<<endl;
    }
}

Measured memory_bytes: 14492
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';

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

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

using namespace std;

int main(void){
    ll N, M, amax=1;
    cin>>N>>M;
    ll a[100005], d=1;
    rep(i, N){
        cin>>a[i];
        //amax=max(amax, a[i]);
        if(i==0){
            while(true){
                if(a[i]%2!=0) break;
                a[i]/=2;
                d*=2;
            }
        }
        else{
            if(a[i]%d!=0){
                cout<<0<<endl;
                return 0;
            }
            a[i]/=d;
            if(a[i]%2==0){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    d/=2;
    rep(i, N){
        a[i]*=d;
    }
    ll LCM=1;
    rep(i, N){
        LCM=lcm(LCM, a[i]);
    }
    //cout<<lcm<<endl;
    ll ans=(ll)((M/LCM)+1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
n,q = map(int, raw_input().split())
que = []
for i in range(n):
	inp = map(str, raw_input().split())
	que.append([inp[0],int(inp[1])])
mxt = sum([y for x,y in que])
t = 0
i = 0
while t < mxt:
	i %= n
	if que[i][1] <= q:
		t += que[i][1]
		print que[i][0],t
		que.pop(i)
		n -= 1
	else:
		t += q
		que[i][1] -= q
		i += 1

Measured memory_bytes: 14020
import java.util.Scanner;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.nextLine().toCharArray();
			if ((0 == (s.length & 1)) == (s[0] == s[s.length - 1])) {
				System.out.println("First");
			} else {
				System.out.println("Second");
			}
		}
	}
}


Measured memory_bytes: 28104
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;

int main() {
	int N;
	double M;
	double L;
	double P;
	cin >> N;
	if (N % 2 == 0) {
		P = 1.0 / 2.0;
		cout << setprecision(10) << P << endl;
	}else{
		L = N;
		M = ((L - 1) / 2 + 1) / L;
		cout << setprecision(10) << M << endl;
	}
}

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

void LCS(string s1,string s2,int n,int m)
{
    int dp[n+1][m+1];
    int i,j;

    memset(dp,-1,sizeof(dp));

    for(i = 0; i <= n; i++) //Initializing the first column
        dp[i][0]=0;
    for(i = 0; i <= m; i++) //Initializing the first row
        dp[0][i]=0;

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= m; j++)
        {
            if(s1[i-1] == s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string s="";

    i = n,j=m;
    while(i>0 && j>0)
    {
        if(s1[i-1] == s2[j-1])
        {
            s+=s1[i-1];
            i--,j--;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }

    }
    reverse(s.begin(),s.end());

    cout<<s<<endl;
    //return dp[n][m];
}
int main()
{
    int n,m;
    string s1,s2;

    getline(cin,s1);
    getline(cin,s2);
    n = s1.size();
    m = s2.size();

    LCS(s1,s2,n,m);

}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int main(void){
  long a,b,x;
  cin >> a >> b >> x;
  
  long A = (a + x - 1) / x;
  long B = b / x;
  
  if(a == b && a % x == 0)
    cout << 1 << endl;
  else if(a == b)
    cout << 0 << endl;
  else
  cout << B - A + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		if((A+B)%2==0) {
			System.out.println((A+B)/2);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 22740
# -*- coding: utf-8 -*-
"""
A - White Cells
https://atcoder.jp/contests/abc121/tasks/abc121_a

"""
import sys


def main(args):
    H, W = map(int, input().split())
    h, w = map(int, input().split())
    ans = (H * W) - (H * w) - (W * h) + (w * h)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


H,W = MI()
a = [LS2() for _ in range(H)]

from collections import defaultdict

d = defaultdict(int)
for i in range(H):
    for j in range(W):
        d[a[i][j]] += 1

if H % 2 == 0 and W % 2 == 0:
    for key in d.keys():
        if d[key] % 4 != 0:
            print('No')
            exit()
    print('Yes')

if H % 2 == 0 and W % 2 != 0:
    H,W = W,H

if H % 2 != 0 and W % 2 == 0:
    a = 0  # 登場回数が4で割って2余るような、英小文字の個数
    for key in d.keys():
        if d[key] % 2 != 0:
            print('No')
            exit()
        elif d[key] % 4 != 0:
            a += 1
    if a <= W//2:
        print('Yes')
        exit()
    else:
        print('No')
        exit()

if H % 2 != 0 and W % 2 != 0:
    a,b = 0,0  # 登場回数が奇数,2(mod 4)であるような、英小文字の個数
    for key in d.keys():
        if d[key] % 4 == 1:
            a += 1
        elif d[key] % 4 == 3:
            a += 1
            b += 1
        elif d[key] % 4 == 2:
            b += 1
    if a <= 1 and b <= H//2 + W//2:
        print('Yes')
        exit()
    else:
        print('No')
        exit()


Measured memory_bytes: 68700
a,b,c,d = map(int, input().split())
if a==b:
    if c==d:
        print('yes')
    else:
        print('no')
elif a==c:
    if b==d:
        print('yes')
    else:
        print('no')
else:
    if b==c:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5596
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 404040
int fac[ N ] , inv[ N ];
void build(){
  fac[ 0 ] = inv[ 0 ] = 1;
  for( int i = 1 ; i < N ; i ++ ){
    fac[ i ] = mul( fac[ i - 1 ] , i );
    inv[ i ] = mypow( fac[ i ] , mod7 - 2 , mod7 );
  }
}
inline int C( int a , int b ){
  return mul( fac[ a ] , mul( inv[ b ] , inv[ a - b ] ) );
}
int h , w , a , b;
void init(){
  h = getint();
  w = getint();
  a = getint();
  b = getint();
}
void solve(){
  int ans = 0;
  for( int ih = h - a , iw = b + 1 ; ih >= 1 && iw <= w ; ih -- , iw ++ )
    ans = add( ans , mul( C( ih - 1 + iw - 1 , ih - 1 ) ,
                          C( h - ih + w - iw , w - iw ) ) );
  printf( "%d\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 3456
import java.io.*;

class Main
 {
    public static void main(String[] args) throws IOException
    {

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

      String str =br.readLine();
      int x = Integer.parseInt(str);


       System.out.println( x*x*x );

   }
 }

Measured memory_bytes: 24168
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e3+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=924844033;

ll n,k;
bool a[2*M];
ll dp[2*M][M];
ll ted=0;
ll fac[M];
ll res;

int main()
{
	ios::sync_with_stdio(0);
    cin >> n >> k;
    For(rep,0,2)
    For(i,0,k)
    {
        a[ted++]=0;
        for (ll j=i+k;j<n;j+=k)
            a[ted++]=1;
    }
    dp[0][0]=1;   
    For(i,0,ted)
    {
        For(j,0,n+1)
        {
            dp[i+1][j]=dp[i][j];
        }
        if (a[i]) For(j,1,n+1)
        {
            dp[i+1][j]+=dp[i-1][j-1];
            dp[i+1][j]%=mod;
        }
    }      
    fac[0]=1;
    For(i,1,n+1) fac[i]=(i*fac[i-1])%mod;
    ll res=0;
    For(i,0,n+1)
    {
        //ER(i);ER(dp[ted][i]);
        if (i%2) res-=dp[ted][i]*fac[n-i];
        else res+=dp[ted][i]*fac[n-i];   
        res+=mod;
        res%=mod;
    }
    RET(res);      
}

Measured memory_bytes: 62976
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

a, p = nm()
print((3 * a + p) // 2)

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

int main() {
    ll a, b, c;
    scanf("%lld %lld.%lld", &a, &b, &c);
    printf("%lld\n", a * (b * 100 + c) / 100);
    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    string s;
    cin >> s;
    int n = int(s.length());
    vi result(n);

    int flag1 = 0;
    int flag2 = 0;
    int x;
    rep(i,n-1){
        if(s[i]=='R' && s[i+1]=='L'){
            result[i]++;
            result[i+1]++;
            result[i] += int(floor(float(i - flag2)/2));
            result[i+1] += int(ceil(float(i - flag2)/2));
            flag1 = i;
        }
        else if(s[i]=='L' && s[i+1]=='R'){
            result[flag1] += int(ceil(float(i - (flag1+1))/2));
            result[flag1+1] += int(floor(float(i - (flag1+1))/2));
            flag2 = i+1;
        }
        else if(i == (n-2)){
            result[flag1] += int(ceil(float(i - flag1)/2));
            result[flag1+1] += int(floor(float(i - flag1)/2));
        }
    }
    rep(i,n-1){
        cout << result[i] << ' ';
    }
    cout << result[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################



x , y = map(int , input().split())

if 2*x <= y <= 4*x and y%2==0:
	print("Yes")
else:
	print("No")






Measured memory_bytes: 9472
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process()throws IOException
    {
        long a=nl(),b=nl(),c=nl(),k=nl(),res=0l;

        res+=Math.min(k, a);
        k=Math.max(0, k-a);

        k=Math.max(0, k-b);

        res-=Math.min(k, c);

        pn(res);
    }
 
 
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();
 
        long s = System.currentTimeMillis();
        int t=1;
       // t=ni();
        while(t-->0)
            process();
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;
 
    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define mod 1000000007
#define maxn 100005

ll n, m, q, t, k;
ll a[maxn];
vector<ll> v[15];

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

	cin >> n;
	string s;
	cin >> s;

	for (int i = 0; i < n; ++i) {
		v[s[i] - '0'].push_back(i);
	}

	ll ans = 0;
	for (ll i = 0; i < 10; ++i) {
		if (v[i].empty())
			continue;
		ll posi = v[i][0];
		for (int j = 0; j < 10; ++j) {
			if (v[j].empty())
				continue;
			vector<ll>::iterator posj = upper_bound(v[j].begin(), v[j].end(),
					posi);
			if (posj == v[j].end())
				continue;

			for (int k = 0; k < 10; ++k) {
				if (v[k].empty())
					continue;

				if (!v[k].empty() && v[k].back() > *posj)
					ans++;
			}
		}
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES

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

using namespace std;

int DP[2001][2001] = {};
int W[5001] = {};
int B[5001] = {};
int W_l[5001] = {};
int B_l[5001] = {};

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N * 2; i++){
		string str;
		int num;
		cin >> str >> num;
		if(str[0] == 'W'){
			W[num] = i;
		}else{
			B[num] = i;
		}
	}
	
	for(int i = 1; i <= N; i++){
		int ret = 0;
		for(int j = i + 1; j <= N; j++){
			if(W[i] > W[j]){
				ret++;
			}
		}
		W_l[i] = ret;
	}
	
	for(int i = 1; i <= N; i++){
		int ret = 0;
		for(int j = i + 1; j <= N; j++){
			if(B[i] > B[j]){
				ret++;
			}
		}
		B_l[i] = ret;
	}
	
	for(int i = 0; i <= N; i++){
		int ss[5001] = {};
		for(int j = i + 1; j <= N; j++){
			ss[W[j]]++;
		}
		for(int j = 1; j <= 2 * N; j++){
			ss[j] += ss[j - 1];
		}
		int BB = 0;
		int sb[5001] = {};
		for(int j = N; j >= 0; j--){
			if(B[j] < W[i]){
				BB++;
			}
			sb[j] = BB;
		}
		
		int start = 0;
		if(i == 0){
			start = 1;
		}
		for(int j = start; j <= N; j++){
			int ret = 10000000;
			if(i != 0){
				ret = DP[i - 1][j] + W_l[i] + sb[j + 1];
			}
			if(j != 0){
				ret = min(ret, DP[i][j - 1] + B_l[j] + ss[B[j]]);
			}
			DP[i][j] = ret;
			/*
			cout << i << " " << j << " ";
			cout << W_l[i] << " " << B_l[j] << " ";
			cout << sb[j] << " " << ss[B[j]] << " ";
			cout << DP[i][j] << endl;
			*/
		}
		//cout << endl;
	}
	
	cout << DP[N][N] << endl;
	
	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int aa = 0, bb = 0;
  for (int i = 0; i < n; i++) {
    if ((aa + bb) >= (a + b) || s[i] == 'c') {
      cout << "No" << endl;
    } else if (s[i] == 'a') {
      aa++;
      cout << "Yes" << endl;
    } else {
      if (bb < b) {
        bb++;
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }

  return 0;
}

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

int n;
string s;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  rep(i, s.length()) {
    char c = s[i] + n;
    if (c > 'Z') c -= 26;
    cout << (char)c;
  }
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m;
pair <int,int> a[100005];
long long sum[100005];

int main()
{
    scanf("%d %d", &n, &m);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d %d", &a[i].first, &a[i].second);
    }
    sort(a+1,a+n+1);
    for(int i = 1;i <= n;i++)
    {
        sum[i] = sum[i-1]+a[i].second;
    }
    sum[n+1] = 1000000000;
    long long ans = 0,i = 1;
    while(1)
    {
        //cout << ans << " ";
        if(sum[i] < m)
        {
            ans += 1LL*a[i].first*a[i].second;
        }
        else
        {
            ans += 1LL*(m-sum[i-1])*a[i].first;
            break;
        }
        i++;
    }
    printf("%lld",ans);
}

#endif // 1++

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

typedef pair<int, int> P;
typedef tuple<int, int, int> triple;

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

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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 int64_t INF = 1e18;

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<int64_t> a(3 * N);
  rep(i, 3 * N) {
    cin >> a[i];
  }

  int64_t front_sum = 0;
  rep(i, N) {
    front_sum += a[i];
  }
  // front_max[i] is the maximum value by [0..i]. i is [N-1, 2*N-1] (the number of candidates is N+1). boundary is right.
  // [0...i] [i+1...]
  //       ^ boundary
  vector<int64_t> front_max(3 * N);
  front_max[N-1] = front_sum;

  // P-queue of front N. We want minimum element to increase sum.
  priority_queue<int64_t, vector<int64_t>, greater<int64_t> > front_q;
  rep(i, N) {
    front_q.push(a[i]);
  }
  for (int i = N; i < 2 * N; ++i) {
    int64_t top = front_q.top();
    if (a[i] > top) {
      // Use a[i] to increase sum.
      front_max[i] = front_max[i-1] - top + a[i];
      front_q.pop();
      front_q.push(a[i]);
    } else {
      front_max[i] = front_max[i-1];
    }
  }
  // For Debug
  // rep(i, 3 * N) {
  //   cout << front_max[i] << endl;
  // }

  int64_t last_sum = 0;
  for (int i = 2 * N; i < 3 * N; ++i) {
    last_sum += a[i];
  }
  // last_min[i] is the minimum value by [i..3*N-1]. i is [N, 2*N] (the number of candidates is N+1). boundary is left.
  // [...i-1] [i...3*N-1]
  //         ^ boundary
  vector<int64_t> last_min(3 * N);
  last_min[2*N] = last_sum;

  // P-queue of last N. We want maximum element to decrease sum.
  priority_queue<int64_t> last_q;
  for (int i = 2 * N; i < 3 * N; ++i) {
    last_q.push(a[i]);
  }
  for (int i = 2 * N - 1; i >= N; --i) {
    int64_t top = last_q.top();
    if (a[i] < top) {
      // Use a[i] to decrease sum.
      last_min[i] = last_min[i+1] - top + a[i];
      last_q.pop();
      last_q.push(a[i]);
    } else {
      last_min[i] = last_min[i+1];
    }
  }
  // For Debug
  // rep(i, 3 * N) {
  //   cout << last_min[i] << endl;
  // }

  int64_t res = - INF;
  // Check the each i with right boundary.
  for (int i = N-1; i < 2 * N; ++i) {
    res = max(res, front_max[i] - last_min[i+1]);
  }
  cout << res << endl;
}


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


int main(int argc, char const *argv[])
{
    int a;
    scanf("%d", &a);
    int b;
    scanf("%d", &b);

    int m = 0;
    if(a < b){
        m += b;
        b--;
    }
    else{
        m += a;
        a--;
    }
    if(a < b){
        m += b;
        b--;
    }
    else{
        m += a;
        a--;
    }


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




    
    return 0;
} 




Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include<cstring>
#include <algorithm>
#include<vector>
using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;

ll dp[2020];

int main()
{
    int n;
    cin >> n;
    dp[3] = 1;
    for (int i = 4; i <= n;i++){
        for (int j = 3; j <= i - 3;j++){
            dp[i] = (dp[i] + dp[i - j]) % mod;
        }

        dp[i]++;
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int dp[105][10005];

int main(void){
    int n, W, v[105], w[105];
    cin >> n >> W;

    for (int i = 0; i < n; i++) cin >> v[i] >> w[i];

    for (int i = 0; i <= W; i++) dp[0][i] = 0;

    for (int i = 0; i < n; i++){
        for (int j = 0; j <= W; j++){
            dp[i + 1][j] = dp[i][j];
            if (w[i] <= j) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }

    int ans = dp[n][W];

    cout << ans << endl;
    

}

Measured memory_bytes: 7016
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll t(n);re(i, n) std::cin >> t[i];
  sort(all(t));
  std::cout << t[n-1] - t[0] << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c) cout << "No" << "\n";
  else if(a!=b&&b!=c&&a!=c) cout << "No" << "\n";
  else cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ll long long int
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>
          ordered_set;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
};

void addEdge(vector<ll> adj[], ll u, ll v)
{
   adj[u].push_back(v);
   adj[v].push_back(u);
}
vector<ll> z_function(string s) {
    ll n = s.length();
    vector<ll> z(n);
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
ll mod=1e9+7;
ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%mod) * (x%mod))%mod;

        // n must be even now
        y = y >> 1; // y = y/2
        x = ((x%mod) * (x%mod))%mod; // Change x to x^2
    }
    return res;
}

int mod1(string num, int a)
{
    // Initialize result
    int res = 0;

    // One by one process all digits of 'num'
    for (int i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}
int main()
{
 	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(b,n);
	if(x==b)
		x--;
	cout<<(a*x)/b<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define MAX 3000
#define MOD 1000000007
using namespace std;
multiset<int> st;
vector<int> v;
bool check()
{
	for(int x:v)
	{
		multiset<int>::iterator it = st.find(x);
		if(it==st.end())
			return false;
		st.erase(it);
	}
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=0,x;i<n;++i)
	{
		cin>>x,st.insert(x);
		v.push_back(abs(n-i-1-i));
	}
	if(!check())
		cout<<"0"<<endl;
	else
	{
		n >>= 1;
		long long ans = 1;
		for(int i=1;i<=n;++i)
			ans *= 2LL, ans %= MOD;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    int n ; cin >> n;
    int cnt = 0, maxx = 0;
    for (int i = 1 ; i <= n ; i++){
        int x , y; cin >> x >> y;
        if (x == y) cnt++;
        else cnt = 0;
        maxx = max(maxx , cnt);
    }
    if (maxx >= 3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main(void)
{
	vector<vector<bool>> ab(4, vector<bool>(4, false));
	for(int i=0; i<3; i++){
		int a, b;
		cin >> a >> b;

		a--;
		b--;

		ab[a][b] = true;
		ab[b][a] = true;
	}

	int odd, even;
	odd = even = 0;
	for(int i=0; i<4; i++){
		int cnt = count(ab[i].begin(), ab[i].end(), true);
		if(cnt%2 == 0)
			even++;
		else
			odd++;
	}

	if(odd == even)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, inf = 1e9 + 7;
int n, prev, a[N][3], dp[N][3];
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < n; ++i)
        for (int j = 0; j < 3; j++)
        {
            dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
        }
    cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]);
}

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

#define int long long

int n, c;
int a[404], b[404];

const int mod = 1e9 + 7;
long long dp[404][404];

signed main()
{
  cin >> n >> c;
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }

  dp[0][0] = 1;
  for (int i = 0; i < n; i++){
    for (int j = a[i]; j <= b[i]; j++){
      int po[404] ={};
      po[0] = dp[i][0];
      for (int k = 0; k <= c; k++){
        if (k) po[k] = (po[k - 1] * j + dp[i][k]) % mod;
        dp[i + 1][k] += po[k];
        dp[i + 1][k] %= mod;
      }
    }
  }

  cout << dp[n][c] << endl;
}


Measured memory_bytes: 1536
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
n, q = MI()
A = []
for i in range(n):
    name, time = input().split()
    A.append((name, int(time)))

queue = deque(A)
time_end = 0
ans_list = []
while len(queue) != 0:
    a = queue.popleft()
    if a[1] <= q:
        time_end += a[1]
        ans_list.append((a[0], time_end))
    else:
        time_end += q
        queue.append((a[0], a[1] - q))

for i in range(n):
    print(' '.join(map(str, ans_list[i])))


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

#define rep(i, N) for(int (i) = 0; (i) < (N); i++)
#define all(v) v.begin(), v.end()
using i64 = int_fast64_t;

int main(){
    i64 N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    auto score = [&](string& T, int i, int j) -> i64 {
        if(T[i-1] == 'r' && j == 2) return P;
        if(T[i-1] == 's' && j == 0) return R;
        if(T[i-1] == 'p' && j == 1) return S;
        return 0;
    };

    i64 ans = 0;
    for(int i = 0; i < K; i++){
        string U = "";
        for(int k = i; k < N; k += K) U += T[k];

        int M = U.size();
        vector<vector<i64>> dp(M+1, vector<i64>(3, 0));
        for(int n = 1; n <= M; n++){
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(j == k) continue;
                    dp[n][j] = max(dp[n][j], dp[n-1][k] + score(U, n, j));
                }
            }
        }
        ans += max({dp[M][0], dp[M][1], dp[M][2]});
    }

    cout << ans << endl;
}

Measured memory_bytes: 5888
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<(a+b)*c/2<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,k,sum=0,y=0;
	cin>>n>>k;
	long long arr[n+1];
	for(long long i=0;i<n;i++){
		cin>>arr[i];
  sum=sum+arr[i];
	}
	if(k==n){
	cout<<sum;}
	else{
		sum=0;
		long long p=sizeof(arr)/sizeof(arr[0]);
		sort(arr,arr+n);
		while(k--){
			sum=sum+arr[y];
			y++;
		}
		cout<<sum;
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin>>s;
    int i,l=s.length();
    stack <char> stk;
    for(i=0;i<l;i++)
        if(stk.empty())
            stk.push(s[i]);
        else if(stk.top()!=s[i])
            stk.pop();
        else
            stk.push(s[i]);
    cout<<l-stk.size();
    return 0;
}

Measured memory_bytes: 512
n=int(input())
h=list(map(int,input().split()))
buf=0
count=0
for i in range(n):
    if i==n-1:
        buf=max(buf,count)
        count=0
        continue
        
    if h[i]>=h[i+1]:
        count+=1
        continue
    buf=max(buf,count)
    count=0
print(buf)

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#define endl '\n'
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
        {
			for(int k=1;k<=n;k++)
			{
				sum += __gcd(i, __gcd(j,k));
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}
int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
  scanf("%d",&M);
  if(solve(0,M))printf("yes\n");
  else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int n;
	std::cin >> n;
	std::vector<int> vec;
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		vec.push_back(a);
	}
	std::sort(vec.begin(), vec.end());
	std::cout << vec[vec.size() - 1] - vec[0] << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n,a,b,c;
	cin >> n;
	a = n/100;
	b = (n / 10) % 10;
	c = n % 10;
	if (a == b && b == c) {
		cout << n << endl;
		return 0;
	}

	else {
		for (int i = n; i <= 999; i++) {
			if (i / 100 == (i / 10) % 10 && (i / 10) % 10 == i % 10) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

	

Measured memory_bytes: 256
import sys
import math
import bisect

def solve(n, m):
    A = [0] * n + [1] * m
    ans = 0
    for i in range(len(A)):
        for j in range(i + 1, len(A)):
            if (A[i] + A[j]) % 2 == 0:
                ans += 1
    return ans

def main():
    n, m = map(int, input().split())
    ans = solve(n, m)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int a,b;
    cin>>a>>b;
    vector<int> v(3,0);
    rep(i,3){
        if(i+1==a){
            v[i]=1;
        }
        if(i+1==b){
            v[i]=1;
        }
    }
    rep(i,3){
        if(v[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }




    
return 0;
}


Measured memory_bytes: 256
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print()


Measured memory_bytes: 7008
N = int(input())

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

A=[-1 for x in range(N)]
i=0
j=0
for a in B:
  j=i+1
  if A[i]==-1:
    A[i]=a
    A[j]=a
  else:
    if A[i]>a:
      A[i]=a
    A[j]=a
  i=i+1
  #print(A)
total = 0
for num in A:
  total = total + num
print(total)
  


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

void rec(int d, ll val, vector<ll> &all){
    all.push_back(val);

    if(d == 10)return;

    for(int j = -1; j <= 1; j++){
        ll add = (val%10) + j;
        if(add >= 0 && add <= 9) rec(d+1, val*10+add, all);
    }
}

int main(){
    int k;
    cin >> k;
    vector<ll> all;
    for(int i = 1; i < 10; i++) rec(1, i, all);

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

    cout << all[k-1] << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<algorithm>
using namespace std ;

typedef pair<int,int> P ;
#define F first
#define S second

int N , table[100100] ;
priority_queue<P,vector<P>,greater<P> > minPQ ;
map<int,int> MP ;

main(){
	cin >> N ;
	for( int i=0 ; i<N ; i++ ) cin >> table[i] ;
	minPQ.push( P(0,0) ) ;
	
	int pos , num ;
	while( minPQ.size() ){
		num = minPQ.top().F ;
		pos = minPQ.top().S ;
		minPQ.pop() ;
		
		if( pos == N-1 ) break ;
		if( MP[pos] ) continue ;
		else MP[pos] = 1 ;
		
		if( table[pos] ){
			if( table[pos]>0 ) minPQ.push( P( num , min(N-1,pos+table[pos]) ) ) ;
			else               minPQ.push( P( num , max( 0 ,pos+table[pos]) ) ) ;
		}
		else {
			for( int i=1 ; i<=6 ; i++ ){
				minPQ.push( P( num+1 , min(N-1,pos+i) ) ) ;
			}
		}
	}
	
	cout << num << endl ;
}

Measured memory_bytes: 6024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int dp[5010][5010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int n=len(s),m=len(t);
    string ans;
    FOR(i,1,n+1){
      FOR(j,1,m+1){
        if(s[i-1]==t[j-1]){
          dp[i][j]=dp[i-1][j-1]+1;
        }else{
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
      }
    }
    int now=dp[n][m];
    for(int i=n;i>=1;i--){
      for(int j=m;j>=1;j--){
        if(s[i-1]==t[j-1] && dp[i-1][j-1]==now-1){
          ans.push_back(s[i-1]);
          now--;
          i--;
        }
      }
    }
    reverse(begin(ans),end(ans));
    cout<<ans<<endl;
}

Measured memory_bytes: 59264