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

using namespace std;

using lint = long long;

const int MOD = int(1e9) + 7;

struct modint {
  int v;
  modint(long long v_ = 0): v(v_ % MOD) { }
  modint operator+ (modint other) {
    return modint(v + other.v);
  }
  modint operator- (modint other) {
    return modint(v - other.v + MOD);
  }
  modint operator* (modint other) {
    return modint((lint)v * other.v % MOD);
  }
  modint operator+= (modint other) {
    (v += other.v) %= MOD;
    return *this;
  }
  modint operator*= (modint other) {
    v = (lint)(v * other.v) % MOD;
    return *this;
  }
  modint operator-= (modint other) {
    (v += MOD - other.v) %= MOD;
    return *this;
  }
};

int N, K;

const int N_ = 2050, K_ = 2050;

modint ways[N_][K_];

int main() {
  scanf("%d%d", &N, &K);

  ways[1][1] = 1;
  for(int i = 1; i <= N; i++) {
    ways[i][1] = 1;
    for(int j = 2; j <= i; j++) {
      ways[i][j] = ways[i][j-1] + ways[i-1][j];
    }
    /*for(int j = 1; j <= i; j++) {
      printf("%6d", ways[i][j].v);
    }
    puts("");*/
  }

  modint ans = ways[N][K];
  for(int i = 0; i < N-K-1; i++) {
    ans *= 2;
  }

  printf("%d\n", ans.v);
  
  return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
 }
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vll h(k+1);
  ll ans=0;
  for(int i=k;i>=1;i--){
    ll num=k/i;
    ll cu=modpow(num,n,MOD);
    ll now=i;
    ll ccu=2;
    while(now*ccu<=k){
      cu-=h[now*ccu];
      if(cu<0) cu+=MOD;
      ccu++;
    }
    h[i]=cu;
    ans+=i*cu;
    ans%=MOD;
  }
  COUT(ans);
}


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

int main(void)
{
	long long int sum = 0;
	int N, M; cin >> N >> M;
	vector<pair<long long int,int>> AB(N);
	for (int i = 0; i < N; i++) {
		long long int A; int B; cin >> A >> B;
		AB[i].first = A;
		AB[i].second = -B;
	}
	sort(AB.begin(), AB.end());
	for (int i = 0; i < N;i++) {
		if (M + AB[i].second < 0) {
			while (M > 0) {
				M--;
				sum += AB[i].first;
			}
			break;
		}
		else {
			M += AB[i].second;
			sum -= AB[i].first*AB[i].second;
		}
	}

	cout << sum << endl;

	return 0;
}

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

#define ENGZ ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define sfi(x) scanf("%d" , &x)
#define sfi2(x, y) scanf("%d%d" , &x,&y)
#define sfl2(x, y) scanf("%I64d%I64d" , &x,&y)
#define sfl(x) scanf("%I64d" , &x)
#define sfl3(x, y, z) scanf("%I64d%I64d%I64d", &x, &y, &z)
#define sfd(x) scanf("%lf", &x)
#define sfd2(x, y) scanf("%lf", &x, &y)
#define sfc(x) scanf("%c", &x)
#define testv(x) cerr << x << ' '
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define test cerr << "here"
#define mod 998244353
#define pi (2*acos(0))
typedef long long ll;
typedef long double ld;

ld low, high, mid, c, t, vel, ans, inc, con, s, bs;
ll a[102][2];

int main() {
    int n, tc;
    bool ch;
        memset(a, 0, sizeof a);
        vel = 0.0;
        ans = 0.0;
        cin >> n;
        assert(n <= 100 && n >= 1);
        for(int i = 1; i <= n; i++)
            cin >> a[i][0], /*assert(a[i][0] <= 200 && a[i][0] >= 1),*/ a[i][0] += a[i - 1][0];
        for(int i = 0; i < n; i++)
            cin >> a[i][1], assert(a[i][1] <= 100 && a[i][1] >= 1);
        for(int i = 0; i < n; i++)
        {
            bs = 0;
            low = a[i][0], high = a[i + 1][0];
            while (bs < 100)
            {
                bs++;
                ch = true;
                mid = (low + high) / 2.0;
                c = min((ld)a[i][1], vel + mid - a[i][0]);
                for(int j = i + 1; ch && j <= n; j++)
                    if(c - a[j][0] + mid > a[j][1])
                        ch = false;
                if (ch)
                    t = mid, low = mid;
                else
                    high = mid;
            }
            bs = 0;
            low = a[i][0];
            high = t;
            while (bs < 100)
            {
                bs++;
                mid = (low + high) / 2.0;
                c = vel + mid - a[i][0];
                if(c > a[i][1])
                    high = mid;
                else
                    low = mid, inc = mid - a[i][0], con = t - mid, s = c;
            }
            ans += inc * (vel + 0.5 * inc) + s * con;
            ans += s * (a[i + 1][0] - t) - 0.5 * (a[i + 1][0] - t) * (a[i + 1][0] - t);
            vel = s - a[i + 1][0] + t;
        }
        cout << fixed << setprecision(6) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,A,B=map(int, input().split())

s=N//(A+B)
NA=N%(A+B)
if(A!=0):
  if(NA<A):
    sA=0
    sAG=NA
  else:
    sA=1
    sAG=0
else:
  sA=0
  sAG=0
print(s*A+sA*A+sAG)

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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=1e6+1;
int cnt[N];

bool go(int x){
    //cnt[x]=1;
    for(int i=2;i*i<=x;i++){
            if(x%i==0){
                if(cnt[i]==1 || cnt[x/i]==1){
                    return false;
                }
                cnt[i]=1;
                cnt[x/i]=1;
            }

    }
    return true;
}

void solve(){
    int n,a[N];
    cin>>n;
    memset(cnt,0,sizeof(cnt));
    For(i,n)cin>>a[i],cnt[a[i]]++;
    sort(a,a+n);
    int val=0;
    for(int i=0;i<n;i++){
        val=__gcd(val,a[i]);


    }
    if(val>1){
            cout<<"not coprime";
            return ;
        }
    For(i,n){
        if((cnt[a[i]]>1 &&a[i]!=1) || !go(a[i])){
            cout<<"setwise coprime";
            return ;
        }
    }
    cout<<"pairwise coprime";


}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t;
    t=1;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


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

int main()
{
    int a , b;
    char op;
    while(1)
    {
        cin >> a >> op >> b;
        if(op == '+')
        {
            cout << a + b << endl;

        }else if(op == '-')
        {

            cout << a - b << endl;
        }else if(op == '*')
        {
            cout << a * b << endl;
        }else if(op == '/')
        {

            cout << a / b << endl;
        }else if(op == '?')
        {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void)
{ char s[100000];
 int a,i;
  scanf("%s",s);
 for(i=0;s[i]!='\0';i++){
   if(s[i]==s[i+1]){
     if(s[i]=='0'){
       s[i+1]='1';
       a++;}
     else if(s[i]=='1'){
       s[i+1]='0';
     a++;}
  }
 }
 printf("%d",a);
 return(0);
}
    

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << (double)w*h/2 << sp << (x*2==w and y*2==h) << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
from math import ceil

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
F = np.array(list(map(int, input().split())))

A.sort()
F.sort()

if np.sum(A) <= K:
    print(0)
else:
    st = 0
    ed = 10 ** 12
    md = ceil((st + ed) / 2)
    while True:
        if np.sum(A - np.minimum(A, md // F[::-1])) <= K:
            ed = md
        else:
            st = md
        md = ceil((st + ed) / 2)

        if md == ed:
            break

    print(md)


Measured memory_bytes: 37284
#include<stdio.h>
#include<string.h>
int main(){
    char str[4];
    scanf("%s",str);
    if(strcmp(str,"SUN") == 0){
        printf("7");
    }
    if(strcmp(str,"MON") == 0){
        printf("6");
    }
     if(strcmp(str,"TUE") == 0){
        printf("5");
    }
     if(strcmp(str,"WED") == 0){
        printf("4");
    }
     if(strcmp(str,"THU") == 0){
        printf("3");
    }
     if(strcmp(str,"FRI") == 0){
        printf("2");
    }
     if(strcmp(str,"SAT") == 0){
        printf("1");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i, n, num[105];
	int i2, n2, step;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		step = 0;
		n2 = n;
		
		for (i = 0; i < n; i++){
			scanf("%d", &num[i]);
		}
		
		for (i = 0; i < n; i++){
			for (i2 = 0; i2 < n2; i2++){
				
				if (num[i2] > num[i2 + 1] && i2 + 1 < n2){
					
					num[i2] += num[i2 + 1];
					num[i2 + 1] = num[i2] - num[i2 + 1];
					num[i2] -= num[i2 + 1];
					step++;
				}
				
			}
		}
		
		
		printf("%d\n", step);
	}
	return (0);
}
					

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(n);
  
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    x[a-1]++;
    x[b-1]++;
  }
  
  for(int i=0;i<n;i++){
    cout << x[i] << endl;
  }
  return 0;
  
    
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int, int);

int main(){
    int K;
    scanf("%d", &K);
    long sum = 0;

    for (int i = 1; i < K+1; i++){
        for (int j = 1; j < K+1; j++){
            for (int k = 1; k < K+1; k++){
                int ij_gcd = gcd(i, j);
                int ijk_gcd = gcd(k, ij_gcd);
                sum += ijk_gcd;
            }
        }
    }

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

    return 0;
}

int gcd(int x, int y)
 {
     int t;
 
     while (y != 0) {
         t = x % y;  x = y;  y = t;
     }
     return x;
 }

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

void fnInput(vector<string>& rvsStrX, vector<string>& rvsStrY)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i)
  {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string>& cnrvsStrX, const vector<string>& cnrvsStrY)
{
  vector<vector<int>> vvnLcsDP;
  for (int i = 0; i < cnrvsStrX.size(); ++i)
  {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();

    vvnLcsDP.clear();
    vvnLcsDP.resize(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	ll first,second,third;
	Data()=default;
	Data(ll f,ll s,ll t):first(f),second(s),third(t){}
};

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

	int N=in();
	vector<ll> F(N);
	ll sumT=0,sumA=0;
	REP(i,N){
		ll t=in(),a=in();
		F[i] = t+a;
		sumA += a;
	}
	sort(ALL(F),greater<ll>());
	for(int i=0;i<N;i+=2){
		sumT += F[i];
	}
	
	out(sumT-sumA);
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	double r1, r2;
	cin >> r1 >> r2;
	cout << setprecision(10);
	cout << r1*r2/(r1+r2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int h, w;
    char a[100][100];
    int row[100], col[100];

    scanf("%d%d", &h, &w);
    scanf("\n");
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            scanf("%c", &a[i][j]);
        scanf("\n");
    }

    for (int i = 0; i < h; i++) {
        row[i] = 0;
        for (int j = 0; j < w; j++)
            if (a[i][j] == '#')
                row[i] = 1;
    }

    for (int j = 0; j < w; j++) {
        col[j] = 0;
        for (int i = 0; i < h; i++)
            if (a[i][j] == '#')
                col[j] = 1;
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            if (row[i] && col[j])
                printf("%c", a[i][j]);
        if (row[i])
            printf("\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main(){
  string x, y;
  cin >> x; y = x;
  reverse(y.begin(), y.end());
 
  if(x == y) cout << "Yes" << endl;
  else cout << "No"  << endl;
 
  return 0;
 
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

L = [i+A[i] for i in range(N)]
R = [i-A[i] for i in range(N)]

p = {}
m = {}
for i in range(N):
    if L[i] not in p:
        p[L[i]] = 1
    else:
        p[L[i]] += 1
for i in range(N):
    if R[i] not in m:
        m[R[i]] = 1
    else:
        m[R[i]] += 1

lower = max(min(p), min(m))
upper = min(max(p), max(m))
ans = 0
for x in range(lower, upper + 1):
    if x in p and x in m:
        ans += p[x] * m[x]

print(ans)

Measured memory_bytes: 172068
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        h:usize,
        w:usize,
        k:usize,
        c:[Chars;h],
    }
    let max: usize = c
        .iter()
        .map(|s| s.iter().filter(|&&t| t == '#').count())
        .sum();
    let mut ans = 0;
    for i in 0..(1 << h) {
        for j in 0..(1 << w) {
            let mut delete = 0;
            for b in 0..h {
                let mask = 1 << b;
                if i & mask != 0 {
                    for k in 0..w {
                        if c[b][k] == '#' {
                            delete += 1;
                        }
                    }
                }
            }
            for b in 0..w {
                let mask = 1 << b;
                if j & mask != 0 {
                    for k in 0..h {
                        let mask2 = 1 << k;
                        if i & mask2 == 0 && c[k][b] == '#' {
                            delete += 1;
                        }
                    }
                }
            }
            if max - delete == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec w(n);
    init(w);
    vec rui(n);
    rui[0] = w[0];

    For(i, 1, n - 1) rui[i] = rui[i - 1] + w[i];
    int mi = INF;
    For(i, 0, n - 2) {
        int x = rui[i] - (rui[n - 1] - rui[i]);
        mi = min(abs(x), mi);
    }
    print(mi);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
existing_list = list(map(int,input().split()))

counts = 0 
while all(num%2 ==0 for num in existing_list):
    length = 0
    for a in existing_list:
        division = a/2
        existing_list[length]=division
        length +=1
    counts +=1

print(counts)

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

bool ask(ll  x) {
    cout << "? " << x << "\n";
    char c; cin >> c;

    return  c == 'Y';
}

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

    if (ask(1e10))   {
        int ans = 1;
        for(int i = 0 ; i < 11 ; ++i)
            if (ask(pow(10ll,i) + 1))   {
                ans = pow(10ll,i);
                break;
            }
        
        cout << "! " << ans;
        return  0;
    }

    ll  l, r;

    for(int i = 1 ; i <= 12 ; ++i)
        if(!ask(pow(10ll,i))) {
            r = pow(10ll,i) - 1;
            l = pow(10ll,i - 1);

            break;
        }
    while (l < r)   {
        ll  m = (l + r) / 2;

        if (ask(m * 10))    r = m;
        else                l = m + 1;   
    }
    cout << "! " << l << "\n";
}

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

using namespace std;

const int N = 100000 + 7;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  scanf("%lld", &n);
  ll a[N];
  ll sum = 0;
  ll neg = 0;
  ll minn = LLONG_MAX;
  for(int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    sum += abs(a[i]);
    if(a[i] < 0) ++neg;
    minn = min(minn, abs(a[i]));
  }
  if(neg % 2 == 1) {
    sum -= 2 * minn;
  }
  printf("%lld\n", sum);
  return 0;
}


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

using namespace std;
#define ll long long int
int A[200002],B[200002];

int main(){
    int t=1;
    //cin >> t;
    while (t--) {
        ll n, m ,ms;
        cin>>n>>m>>ms;
 
        for(int A_i = 0; A_i < n; A_i++){
            cin>>A[A_i];
        }
        for(int B_i = 0; B_i < m; B_i++){
           cin>>B[B_i];
        }

        ll sum = 0;
        ll x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        ll ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

        cout<<ans<<"\n";
    }
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    int A[N], B[N];
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    sort(A, A+N);
    sort(B, B+N);
    int sum;
    if(N % 2 == 1){
        int min_x = A[N/2];
        int max_x = B[N/2];
        sum = max_x - min_x + 1;
    }else{
        int min_x = A[N/2-1] + A[N/2];
        int max_x = B[N/2-1] + B[N/2];
        sum = max_x - min_x + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    ll ans_plus = 0;
    vector<ll> sum_plus(n,0);
    if(a[0] > 0){
        sum_plus[0] = a[0];
    }else{
        ans_plus += 1 - a[0];
        sum_plus[0] = 1;
    }
    for (ll i = 1; i < n; ++i) {
        sum_plus[i] = sum_plus[i - 1] + a[i];
        if(sum_plus[i] * sum_plus[i - 1] > 0) {
            if (sum_plus[i - 1] > 0) {
                ans_plus += 1 + sum_plus[i];
                sum_plus[i] = -1;
            } else if (sum_plus[i - 1] < 0) {
                ans_plus += 1 - sum_plus[i];
                sum_plus[i] = 1;
            }
        }else if(sum_plus[i] == 0){
            if(sum_plus[i - 1] > 0){
                sum_plus[i] = -1;
            }else if(sum_plus[i - 1] < 0){
                sum_plus[i] = 1;
            }
            ans_plus++;
        }
    }


    ll ans_minus = 0;
    vector<ll> sum_minus(n);
    if(a[0] < 0){
        sum_minus[0] = a[0];
    }else{
        ans_minus += 1 + a[0];
        sum_minus[0] = -1;
    }
    for (ll i = 1; i < n; ++i) {
        sum_minus[i] = sum_minus[i - 1] + a[i];
        if(sum_minus[i] * sum_minus[i - 1] > 0) {
            if (sum_minus[i - 1] > 0) {
                ans_minus += 1 + sum_minus[i];
                sum_minus[i] = -1;
            } else if (sum_minus[i - 1] < 0) {
                ans_minus += 1 - sum_minus[i];
                sum_minus[i] = 1;
            }
        }else if(sum_minus[i] == 0){
            if(sum_minus[i - 1] > 0){
                sum_minus[i] = -1;
            }else if(sum_minus[i - 1] < 0){
                sum_minus[i] = 1;
            }
            ans_minus++;
        }
    }
    print(min(ans_minus,ans_plus));
}



Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
int m[101];
ll l[101];
int s[101][17],e[101][17];
ll dp[2][1<<17];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%d %lld",&m[i],&l[i]);
			for(int j=0;j<m[i];j++){
				scanf("%d %d",&s[i][j],&e[i][j]);
				s[i][j]-=6;
				e[i][j]-=6;
			}
		}
		for(int i=0;i<2;i++){
			for(int j=0;j<(1<<17);j++){
				dp[i][j]=-1;
			}
		}
		dp[0][0]=0;
		ll res=0;
		for(int i=0;i<n;i++){
			memset(dp[(i+1)%2],-1,sizeof(dp[(i+1)%2]));
			for(int j=0;j<(1<<17);j++){
				if(dp[i%2][j]>=0){
					dp[(i+1)%2][j]=max(dp[(i+1)%2][j],dp[i%2][j]);
					res=max(dp[(i+1)%2][j],res);
					bool flag=true;
					for(int k=0;k<m[i];k++){
						for(int l=s[i][k];l<e[i][k];l++){
							if(j>>l & 1)flag=false;
						}
					}
					if(flag){
						int nj=j;
						for(int k=0;k<m[i];k++){
							for(int l=s[i][k];l<e[i][k];l++){
								nj=nj| (1<<l);
							}
						}
						dp[(i+1)%2][nj]=max(dp[(i+1)%2][nj],dp[i%2][j]+l[i]);
						res=max(dp[(i+1)%2][nj],res);
					}
				}
			}
		}
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define af(i,a,b) for( int i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

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

const int MAX= 1001;

ll dp[110][100010];
ll v[110];
ll w[110];
int main(){
	fastio;	
	int n,t,ans=0;
	cin>>n>>t;
	f(i,0,n) cin>>w[i+1]>>v[i+1];
	f(i,1,n+1){
		f(j,1,t+1){
			if(j>=w[i])
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i] ]+v[i]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][t];
}

Measured memory_bytes: 79360
sa=input()
sb=input()
sc=input()
a,b,c=0,0,0
t="a"
while 1:
    if(t=="a"):
        if(len(sa)==a):
            break
        else:
            t=sa[a]
            a+=1
    elif(t=="b"):
        if(len(sb)==b):
            break
        else:
            t=sb[b]
            b+=1
    elif(t=="c"):
        if(len(sc)==c):
            break
        else:
            t=sc[c]
            c+=1
print(t.upper())

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n, y;
	cin >> n >> y;
	rep(i, n + 1) {
		rep(j, n + 1) {
			if (n < (i + j)) break;
			ll k = n - (i + j);
			if (y == k * 10000 + j * 5000 + i * 1000) {
				cout << k << endl;
				cout << j << endl;
				cout << i << endl;
				system("pause");
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



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

int main() {
  string S, T;
  cin >> S >> T;
  int N = S.size();
  for (int i = 0; i < N; i++) {
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
    S = S.substr(1, N-1) + S[0];
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
char s[2][105];

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < 2; i++){
        scanf("%s", s[i]);
    }
    for(int i = 0; i < 2 * n; i++){
        std::cout << s[i%2][i/2];
    }
    printf("\n");
}


Measured memory_bytes: 256
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


s = list(S())
c = Counter(s)

a = c.get("a", 0)
b = c.get("b", 0)
c = c.get("c", 0)

if max(a, b, c) - min(a, b, c) >= 2:
    print("NO")
else:
    print("YES")


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  vector<P> a(N),c(N);
  rep(i,N) cin >> a[i].first >> a[i].second ;
  rep(i,N) cin >> c[i].first >> c[i].second ;
  sort(ALL(a));
  reverse(ALL(a));
  vector<bool> used(N,false);
  int ans = 0;
  rep(i,N){
    int aa,bb;
    int mi = INF;
    int arg = -1;
    tie(aa,bb) = a[i];
    rep(j,N){
      if(used[j]) continue;
      if(c[j].first<=aa||c[j].second<=bb) continue;
      if(chmin(mi,c[j].second)) arg = j;
    }
    if(arg==-1) continue;
    used[arg] = true;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007//10^9+7
#define PI acos(-1)

using namespace std;

int compare_int(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}

int main(void)
{
	//変数の宣言
	int n;
	int a[200010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	qsort(a,n,sizeof(int),compare_int);

	i=0;
	temp1=0;
	temp2=0;
	while(i<n-1){
		if(a[i]==a[i+1]){
			temp2=temp1;
			temp1=a[i];
			i++;
		}

		if(temp2!=0){
			break;
		}
		i++;
	}


	//	printf("計算部分終了\n");

	//出力

	printf("%lld",temp1*temp2);

	//	printf("結果の出力終了\n");


	return 0;
}



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

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<pair<int, int> > p(n);

  rep(i, n) {
    int a; cin >> a;
    p[i] = make_pair(a, i);
  }
  
  sort(p.begin(), p.end());

  int ans = 0;
  rep(i, n) {
    if ( p[i].second%2 != i%2 ) { ans++; }
  }

  cout << (ans+1)/2 << endl;

  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int w = int.Parse(input[0]);
      int h = int.Parse(input[1]);
      int n = int.Parse(input[2]);
      
      List<int> xya = new List<int>();
      
      int xs = 0;
      int xl = w;
      int ys = 0;
      int yl = h;
      
      for (int i=0;i<n;i++)
      {
        xya = Console.ReadLine().Split().ToList().ConvertAll(x=>int.Parse(x));
        if (xya[2]==1)
        {
          xs=Math.Max(xya[0],xs);
        }
        if (xya[2]==2)
        {
          xl=Math.Min(xya[0],xl);
        }
        if (xya[2]==3)
        {
          ys=Math.Max(xya[1],ys);
        }
        if (xya[2]==4)
        {
          yl=Math.Min(xya[1],yl);
        }       
        
      }
      
      //Console.WriteLine("xs : "+xs+" , "+"xl : "+xl+" , "+"ys : "+ys+" , "+"yl : "+yl);
      if ((xl-xs)<0 || (yl-ys)<0)
      {
        Console.WriteLine(0);
      }
      else
      {
        Console.WriteLine((xl-xs)*(yl-ys));
      }
    }
}


Measured memory_bytes: 28344
#include <iostream>
#include <utility>
#include <vector>
#include <map>

void print(std::vector<std::pair<int, char>>& readVec){
    int n = readVec.size();
    for(int i = 0; i < n; ++i){
        std::cout << readVec.at(i).second << readVec.at(i).first;
        if(n - 1 != i){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
}

bool isStable(std::multimap<int, char>& readMmp, std::vector<std::pair<int, char>>& readVec){
    int n = readMmp.size(), m = readVec.size();

    if(n != m){
        return false;
    }

    bool flg = true;
    auto mmpItr = readMmp.begin();
    auto vecItr = readVec.begin();
    while(flg && readMmp.end() != mmpItr && readVec.end() != vecItr){
        flg = mmpItr->first == vecItr->first && mmpItr->second == vecItr->second; 
        ++mmpItr;
        ++vecItr; 
    }

    if(flg){
        std::cout << "Stable" << std::endl;
    }else{
        std::cout << "Not stable" << std::endl;
    }

    return true;
}

int bubbleSort(std::vector<std::pair<int, char>>& readVec){
    int n = readVec.size(), count = 0;
    bool flg = true; // existence of the left-adjacent element less than an interest one.
    while(flg){
        flg = false;
        for(int j = n - 1; 0 < j; --j){
            if(readVec.at(j).first < readVec.at(j - 1).first){
                std::swap(readVec.at(j), readVec.at(j - 1));
                flg = true;
                ++count;
            }
        }
    }

    print(readVec);

    return count;
}

int selectionSort(std::vector<std::pair<int, char>>& readVec){
    int n = readVec.size(), count = 0;
    for(int i = 0; i < n; ++i){
        int minJ = i;
        for(int j = i; j < n; ++j){
            if(readVec.at(j).first < readVec.at(minJ).first){
                minJ = j;
            }
        }
        
        if(i != minJ){
            std::swap(readVec.at(i), readVec.at(minJ));
            ++count;
        }
    }

    print(readVec);

    return count;
}

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

    std::vector<std::pair<int, char>> a(n);
    std::multimap<int, char> mmp;
    for(int i = 0; i < n; ++i){
        std::string str;
        std::cin >> str;
        a.at(i) = std::make_pair(str.at(1) - 48, str.at(0));
        mmp.insert(std::make_pair(str.at(1) - 48, str.at(0)));
    }

    auto bubbled = a, selected = a;

    bubbleSort(bubbled);
    isStable(mmp, bubbled);

    selectionSort(selected);
    isStable(mmp, selected);

    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include<string>
#include<iomanip>

using namespace std;

int main(void) {
	int N;
	int i,j;

	double x[10];
	char u[3];
	double b = 0;
	double m = 0;
	double g = 0;

	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> x[i];
		for (j = 0; j < 3; j++) {
			cin >> u[j];
		}

		if ((u[0] == 'J') && (u[1] == 'P') && (u[2] == 'Y'))
			m = m + x[i];
		else if ((u[0] == 'B') && (u[1] == 'T') && (u[2] == 'C'))
			b = b + x[i];
	}
	b = b * 380000;
	g = m + b;

	std::cout << std::fixed;
	std::cout << std::setprecision(8)<<g;

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
w,u=3*m,n-1
o,f,i=998244353,[1],1
while i<w+n:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
a=c(w+u,u)-n*c(n+m-2,u)
while-~m<min(w,n):m+=2;a-=c(n,m)*c(2*u+w-m>>1,u)
print(a%o)

Measured memory_bytes: 115556
#include <iostream>
#include <iomanip>
using namespace std;
#define PI 3.14159265358979323846;
 
int main(void){
    long double r;
    
    cin >> r;
    r = 2 * r * PI;
    cout << fixed << setprecision(20);
    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 3792
#include<iostream>
#include<functional>
#include<algorithm>
#include<vector>
#include<tuple>
#include<queue>

#define LL long long
#define INF (1<<30)
#define LINF (1000000000000000)
#define PP std::pair<int,int>
int N, M;
int sum;
int main() {
	std::cin >> N >> M;
	sum += 100 * (N - M);
	sum += 1900 * M;
	for (int i = 0; i < M; i++) {
		sum *= 2;
	}
	std::cout << sum << std::endl;
	return 0;
}


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

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

	string S,sub;
	cin >> S;
	
	sub = S;

	while (sub.find("()") != -1) {
		sub.erase(sub.find("()"),2);
	}

	int left,right;
	left = count(sub.begin(), sub.end(), '(');
	right = count(sub.begin(), sub.end(), ')');

	for (int i = 0; i < right; i++)cout << "(";
	cout << S;
	for (int i = 0; i < left; i++)cout << ")";
	cout << endl;

}

Measured memory_bytes: 256
import sys
n,m = list(map(int, input().split()))
students = [list(map(int, input().split())) for _ in range(n)]
ckeckpoints = [list(map(int, input().split())) for _ in range(m)]
for i, student in enumerate(students):
  min_j = 0
  min_norm = sys.maxsize
  for j, ckeckpoint in enumerate(ckeckpoints):
    norm = abs(student[0] - ckeckpoint[0]) + abs(student[1] - ckeckpoint[1])
    if norm < min_norm:
      min_j = j
      min_norm = norm
  print(min_j+1)


Measured memory_bytes: 3188
from collections import deque

S = list(input())
Q = int(input())

d = deque(S)
head = "l"

for _ in range(Q):
    q = input()
    if len(q) == 1:
        if head == "l":
            head = "r"
        else:
            head = "l"
    else:
        T, F, C = q.split()
        if int(F) == 1:
            if head == "l":
                d.appendleft(C)
            else:
                d.append(C)
        else:
            if head == "l":
                d.append(C)
            else:
                d.appendleft(C)
if head == "l":
    print("".join(list(d)))
else:
    print("".join(list(d)[::-1]))


Measured memory_bytes: 73336
# coding: utf-8
# Your code here!
K,A,B = map(int,input().split())

if A+1 >= B:
    print(1+K)
else:
    if 1+K < A:
        print(1+K)
    else:
        tmp = A-1
        koukan = (K-tmp)//2
        ans = koukan*(B-A)+(K-koukan*2)+1
        print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define long long long
const int MAXN = 1e6 + 7;
const long MOD = 1e9 + 7;
const long INF = 1e15;


main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int i, j, k;

    string S; cin >> S;
    int N = S.length();
    int A[N]; memset(A, 0, sizeof(A));

    int nextR = 0;
    for (i = 0; i < N; ++i) if (S[i] == 'R') {
        nextR = max(nextR, i);
        while (S[nextR] == 'R') ++nextR;
        int dist = nextR - i;
        if (dist & 1) ++A[nextR - 1];
        else ++A[nextR];
    }

    int prevL = N - 1;
    for (i = N - 1; i >= 0; --i) if (S[i] == 'L') {
        prevL = min(prevL, i);
        while (S[prevL] == 'L') --prevL;
        int dist = i - prevL;
        if (dist & 1) ++A[prevL + 1];
        else ++A[prevL];
    }

    for (i = 0; i < N; ++i) cout << A[i] << " ";
    cout << "\n";
}

Measured memory_bytes: 1104
N = int(input())
A = list(map(int, input().split()))
a = [0]*(N+1)
ans = [0]*(N)

for i in range(1,N+1):
    a[i] = i


pairs = zip(A, a)
sortedpairs = sorted(pairs, key=lambda x: x[0])

for i in range(N):
    ans[i] = sortedpairs[i][1]+1

#print(ans)
print(' '.join(map(str, ans)))

Measured memory_bytes: 28896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
const int MAXN = 2e5 + 10;
inline LL in()
{
    LL x = 0, flag = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
    return x * flag;
}
int n, m, ans, kind;
LL xsum, ori[MAXN], tar[MAXN], tot[MAXN];
int a[MAXN], b[MAXN], size[MAXN];
bool vis[MAXN];
int fa[MAXN];
int find(int x)
{
	if (fa[x] != x) fa[x] = find(fa[x]);
	return fa[x];
}
void unite(int x, int y)
{
    int fx = find(x), fy = find(y);
    if (fx == fy) return;
	fa[fy] = fx;
    size[fx] += size[fy];
}
bool cmp(int x, int y)
{
    return ori[x] < ori[y];
}
bool judge()
{
	map <LL, int> cnt;
    for (int i = 1; i <= n+1; i ++)
        cnt[ori[i]] ++;
    for (int i = 1; i <= n; i ++)
    {
        if (cnt[tar[i]] > 0)
	        cnt[tar[i]] --;
	    else 
	        return false;
    }
    return true;
}
void init()
{
	map <LL, int> id; 
    sort(tot + 1, tot + n + 2);
    id[tot[1]] = kind = 1;
    for (int i = 2; i <= n + 1; i ++)
    {
        if (tot[i] != tot[i-1]) kind ++;
        id[tot[i]] = kind;
    }
    for (int i = 1; i <= n+1; i ++)
    {
        a[i] = id[ori[i]];
        b[i] = id[tar[i]];
    }
}
int main()
{
	n = in();
	for (int i = 1; i <= n; i ++) 
    {
        tot[i] = ori[i] = in();
        ori[n + 1] ^= ori[i];
    }
    tot[n + 1] = ori[n + 1];
	for (int i = 1; i <= n; i ++) 
	{
		tar[i] = in();
		tar[n + 1] ^= tar[i];	
	}
    if (judge() == false) 
    {
        printf("-1");
        return 0;
    }
    init();
    for (int i = 1; i <= kind; i ++) fa[i] = i;
	for (int i = 1; i <= n + 1; i ++)
	{
		if (a[i] != b[i]) 
		{
			ans ++;
            size[a[i]] ++;
		}
	}
	for (int i = 1; i <= n + 1; i ++)
	{
		if (find(a[i]) == find(b[i])) continue;
		unite(a[i], b[i]);
	}
    for (int i = 1; i <= n + 1; i ++)
    {
        if (fa[a[i]] == a[i] && a[i] != b[i] && !vis[a[i]]) 
		{
			vis[a[i]] = true;
			ans ++;
		}
    }
	if (a[n+1] != b[n+1]) ans --;
	if (size[fa[a[n+1]]] > 1) ans --;
    cout << ans << endl;
	return 0;
}


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

using namespace std;

int const N = 1234567;

int s[N], ans[N];
int z[N];

int was[42];

int main() {
  int c = getchar();
  int n = 0;
  while (c <= 32) c = getchar();
  while (c > 32) {
    s[n++] = c - 'a';
    c = getchar();
  }
  std::reverse(s, s + n);
  int pos = 0;
  int ac = 0;
  int have = 0;
  while (true) {
    int cn = 0;
    for (int i = 0; i < 26; i++) was[i] = 0;
    while (cn < 26 && pos < n) {
      if (!was[s[pos]]) {
        was[s[pos]] = true;
        cn++;
      }
      pos++;
    }
    z[have++] = pos;
    // printf("pos = %d\n", pos);
    if (cn == 26) {
      // ans[ac++] = s[pos - 1];
    } else {
      // for (int i = 0; i < 26; i++) {
      //   if (!was[i]) {
      //     ans[ac++] = i;
      //     break;
      //   }
      // }
      break;
    }
  }
  pos = n - 1;
  for (int i = 0; i < 26; i++) {
    if (!was[i]) {
      ans[ac++] = i;
      break;
    }
  }
  for (int i = have - 2; i >= 0; i--) {
    while (pos >= 0 && s[pos] != ans[ac - 1]) --pos;
    // printf("%d\n", pos);
    --pos;
    for (int j = 0; j < 26; j++) {
      was[j] = 0;
    }
    int to = i == 0 ? 0 : z[i - 1];
    while (pos >= to) was[s[pos--]] = 1;
    bool found = false;
    for (int j = 0; j < 26; j++) {
      if (!was[j]) {
        ans[ac++] = j;
        found = true;
        break;
      }
    }
    assert(found);
  }
  for (int i = 0; i < ac; i++) putchar('a' + ans[i]);
  puts("");
}

Measured memory_bytes: 6400