akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin >> a >> a;
    cout << "A" << a.front() << "C";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n,k; cin >> n >> k;
  vector<int> h(n,0);
  rep(i,k){
    int d; cin >> d;
    rep(j,d){
      int a; cin >> a; a--;
      h[a]++;
    }
  }
  int ans=0;
  rep(i,n) if(h[i]==0) ans++;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define itn int
typedef long long ll;
typedef pair<int,int> p;

vector<int> v(4, 0);
vector<int> ope(3, 0);

void judgeOpe(int a)
{
  switch (a) {
    case -1:
      cout << '-';
      break;
    case 1:
      cout << '+';
      break;
  }
}


void dfs(int pos, int res)
{
  // cout << "pos: " << pos << endl;
  // cout << "res: " << res << endl;
  // cout << "=========" << endl;
  if(pos == 3 && res == 7)
  {
    cout << v[0];
    judgeOpe(ope[0]);
    cout << v[1];
    judgeOpe(ope[1]);
    cout << v[2];
    judgeOpe(ope[2]);
    cout << v[3] << "=7" << endl;
    exit(0);
  }
  else if(pos == 3) return;
  else
  {
    ope[pos] = 1;
    res += v[pos+1];
    dfs(pos+1, res);
    ope[pos] = -1;
    res -= v[pos+1] * 2;
    dfs(pos+1, res);
    return;
  }
}


int main()
{
  string s;
  cin >> s;

  char tmp = s[0];
  v[0] = tmp - '0';
  tmp = s[1];
  v[1] = tmp - '0';
  tmp = s[2];
  v[2] = tmp - '0';
  tmp = s[3];
  v[3] = tmp - '0';
  // for (int i = 0; i < 4; i++)
  // {
  //   cout << v[i] + 1 << endl;
  // }
  dfs(0, v[0]);




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}

int main(){
  ll n; cin >> n;
  
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  map<ll, ll> siz;
  rep(i, n){
    int x; cin >> x;
    siz[x]++;
  }
  ans = siz.size();
  cout << ans << endl;
}

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

using namespace std;

main(){
    string str1;
    string str2;
    int size;
    scanf("%d",&size);
    cin >> str1 >> str2;
    long long ans = 1;
    int mod = 1000000007;
    int i;int ant = 0;
    if(str1[0]==str2[0]){ans*=3;i = 1; ant = 1;}
    else{ans*=6; i=2; ant = 2;}
    for(i;i<size;++i){
        if(str1[i]==str2[i]){
            if(ant==1){ans*=2;ans %= mod;}
            ant = 1;
        }else{
            if(ant==1){ans*=2;ans %= mod;}
            else{ans*=3;ans %= mod;}
            ant = 2;
            i++;
        }
    }
    cout << ans << endl;
}

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

long long f(long long x){
  if(x < 0){
    return x * (-1);
  }
  else{
    return x;
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> p(n,vector<long long>(2));
  vector<vector<long long>> c(m, vector<long long>(2));

  for(int i = 0; i < n; i++){
    cin >> p[i][0] >> p[i][1];
  }
  for(int i = 0; i < m; i++){
    cin >> c[i][0] >> c[i][1];
  }
  vector<int> v(n, m);
  for(int i = 0; i < n; i++){
    long long dist = f(p[i][0] - c[m - 1][0]) + f(p[i][1] - c[m - 1][1]);
    for(int j = m - 2; j >= 0; j--){
      if(f(p[i][0] - c[j][0]) + f(p[i][1] - c[j][1]) <= dist){
        dist = f(p[i][0] - c[j][0]) + f(p[i][1] - c[j][1]);
        v[i] = j + 1;
      }

    }
  }
  for(auto x: v){
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	vector<int> a;
	int in;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		a.push_back(in);
	}
	int ans = 0;
	for (auto &v : a)
	{
		while(v % 2 == 0)
		{
			++ans;
			v /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
def gcd(x,y):
    z = x % y
    if z == 0:
        return y
    return gcd(y, z)

N = int(input())
T = [int(input()) for _ in range(N)]

for i in range(N-1):
   T[i+1] = (T[i] * T[i+1]) // gcd(T[i], T[i+1])
print(T[-1])

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String s = br.readLine();

			int num = Integer.parseInt(s);

			long ans = (long)num * num * num ;

			System.out.println(ans);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

		}
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int a, b;
    while (cin >> a >> b)
    {
        int c = a + b;
        OP((int)log10(c) + 1)
    }
    return 0;
}



Measured memory_bytes: 3336
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


void solve() {
    int N;
    cin >> N;
    vector<int> v(N);
    vector<int> balls(N);

    REP(i,N) cin >> v[i];
    REPR(i,N-1) {
        auto t = i + (i+1);
        auto sm = 0;
        while(t < N) {
            sm += balls[t];
            t += (i+1);
        }
        if(sm%2 != v[i]) balls[i] = 1;
    }
    auto sum = accumulate(ALL(balls),0);

    cout << sum << endl;
    vector<int> ans;
    REP(i,N) if(balls[i]!=0) ans.push_back(i+1);
    ostringstream os;
   const char *delim = " ";
    copy(ALL(ans),ostream_iterator<int>(cout,delim));


}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3064
n=int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      m=i**2+j**2+k**2+i*j+j*k+i*k
      d[m]+=1
for i in range(1,n+1):
  print(d[i])


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N; cin >> N;
    vector<ll> C(N); REP(i,N){ cin >> C[i]; C[i]--;}
    vector<ll> last(200000,0);
    ll dp[N+1]; CLR(dp);
    dp[1] = 1;
    REP(i,N){
        dp[i+1] += dp[i];
        if(last[C[i]] != i) dp[i+1] += dp[last[C[i]]];
        last[C[i]] = i+1;
        dp[i+1] %= MOD;
    }
    ll ans = dp[N];
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 4992
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;

void main(){
    int r, g, b;
    readVars(r, g, b);

    int val = 100 * r + 10 * g + b;

    if (val % 4 == 0) {
        writeln("YES");
    }
    else {
        writeln("NO");
    }
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int dp[1005][1005];

main()
{
	int h, w;
	cin>>h>>w;
	char mat[h][w];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>mat[i][j];
		}
	}
	
	for(int i=0;i<=h;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==1 && j==1)
			{
				dp[i][j]=1;
				continue;
			}
			if(i==0 || j==0) {
				dp[i][j] = 0;
				continue;
			}
			if(mat[i-1][j-1]=='#')
			{
				dp[i][j] = 0;
			}
			else{
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[h][w]<<endl;
	return 0;
	
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>

using namespace std;

int n;
double x;

bool is_jpy[10];
double sum = 0.0;
int main(){
    cin >> n;
    char s[5];
    for(int i=0;i<n;i++){
        cin >> x;
        cin >> s;
        if(s[0]=='J'){
            sum += x;
        }else{
            sum += x*380000.0;
        }
    }

    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL, vector<LL>, greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
//#define MOD 1000000007
#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}

int main(){
  FAST;
  LL i,ans=0,X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  LL p[A],q[B],r[C];
  PQS a,b;
  rep(i,A)cin>>p[i];
  rep(i,B)cin>>q[i];
  rep(i,C)cin>>r[i];
  qsort(p,A,sizeof(LL),lcmpr);
  qsort(q,B,sizeof(LL),lcmpr);
  qsort(r,C,sizeof(LL),lcmpr);
  rep(i,X){
    a.push(p[i]);
    ans+=p[i];
  }
  rep(i,Y){
    b.push(q[i]);
    ans+=q[i];
  }
  rep(i,C){
    if(a.top()<=b.top()&&a.top()<=r[i]){
      ans-=a.top();
      a.pop();
      ans+=r[i];
      a.push(r[i]);
    }else if(b.top()<=a.top()&&b.top()<=r[i]){
      ans-=b.top();
      b.pop();
      ans+=r[i];
      b.push(r[i]);
    }else break;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 5100
public class Main {

	public static void main(String[] args) {
		
		String input_str = new java.util.Scanner(System.in).nextLine();

		String[] str = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
		for(int i = 0; i < 7; i++) {
			if(input_str.equals(str[i])){
				System.out.println(i + 1);
			}
		}
	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  cout << n * (n-1) / 2 << endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x

solve :: Int -> [Int] -> Int -> Int
solve n [] k = k
solve n (a:an) k = if (n * (n + a)) < 0
                   then solve (n+a) an k
                   else if n >= 0 then solve (-1) an (k + abs(-1-n-a))
                                  else solve 1 an (k + abs(1-n-a))

ss :: [Int] -> [([Int],Int)]
ss an
  |(head an) > 0 = [(an , 0),( (-1):(drop 1 an),(head an)+1)]
  |(head an) < 0 = [(an , 0),( 1:(drop 1 an),-(head an)+1)]
  | otherwise =  [(1:(drop 1 an) , 1),((-1):(drop 1 an),1)]
-------------------------------------------------------------
main = do
    _ <- readLn :: IO Int
    an <- map bsreadInt . BC.words <$> BC.getLine
    let ans = [solve (head an) (drop 1 an) k | (an,k) <- (ss an)]
    print $ minimum $ ans
    
    
    
    
    

Measured memory_bytes: 9724
import sys

N, C = map(int, sys.stdin.readline().split())

# 同一チャンネルならtとsが連続していても1台で録画できる
# そのため、通常のimos法ではなく、録画開始・終了のチャンネルを保持する
times = [[set() for _ in range(10**5 + 5)], [set() for _ in range(10**5 + 5)]]
max_t = 0
for _ in range(N):
    s, t, c = map(int, sys.stdin.readline().split())
    # 基本的にs-1だけでよいが、同一チャンネルで録画が連続する場合の対応を入れておく
    times[0][s-1].add(c)
    times[0][s].add(c)
    times[1][t].add(c)
    max_t = max(max_t, t)

ans = 0
recording = set()
for i in range(max_t + 5):
    recording -= times[1][i]
    recording |= times[0][i]
    ans = max(ans, len(recording))

print(ans)

Measured memory_bytes: 57936
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)

template <class T = int>
T in() { T x; std::cin >> x; return x; }
#define output(e) std::cout << e << '\n'

#ifdef LOCAL
#define db std::cout << "L" << __LINE__ <<
#define de << "\n"
#define dv(x) << " " << #x << "->" << x
#else
#define db
#define de
#define dv(x)
#endif

//
// Implementation
//

int main() {
  int N = in();
  string s = in<string>();

  int ans = 0;
  int curr = 0;
  for(int i=1; i<N; i++) {
    if (s[i] != 'W') {
      curr++;
    }
  }
  ans = curr;
  
  for (int i=1; i<N; i++) {
    if (s[i-1] == 'W') {
      curr++;
    }
    if (s[i] == 'E') {
      curr--;
    }
    ans = min(ans, curr);
  }
  output(ans);
}


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

int main()
{
    int N;
    cin >> N;
    string s;
    map<string, int> S;
    REP(i, N){
        cin >> s;
        S[s]++;
    }
    int max_v = 0;
    vector<string> max_k;
    for (auto itr = S.begin(); itr != S.end(); ++itr)
    {
        if(max_v < itr->second) {
            max_v = itr->second;
            max_k.clear();
            max_k.push_back(itr->first);
        }else if(max_v == itr->second){
            max_k.push_back(itr->first);
        }
    }
    for (auto itr = max_k.begin(); itr != max_k.end(); ++itr){
        cout << *itr << endl;
    }
    return 0;
}


Measured memory_bytes: 26868
import collections
S = (input())
T = (input())

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])


indexes = []
indexes2 = []

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes.append(tuple([i for i, x in enumerate(S) if x == k1[0]]))
                indexes2.append(tuple([i for i, x in enumerate(T) if x == k2[0]]))
        if set(indexes) == set(indexes2):
            print('Yes')
        else:
            print('No')
else:
    print('No')

# for k1,k2 in zip(count1, count2, ):
#     if count1[k1] > 1:
#         [100 if i > 0 else i for i in l]


Measured memory_bytes: 20344
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n), c(n), diff(n);

  rep(i, n) {
    cin >> v[i];
  }

  rep(i, n) {
    cin >> c[i];
  }

  rep(i,n) {
    diff[i] = v[i] - c[i];
  }
  ll ans = 0;
  for (auto itr : diff) 
    if (itr > 0) ans += itr;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H')
      cout<<"H"<<endl;
    if(b=='D')
      cout<<"D"<<endl;
  }
  if(a=='D'){
    if(b=='H')
      cout<<"D"<<endl;
    if(b=='D')
      cout<<"H"<<endl;
  }
}

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

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

  for (int i = 1000; i <= 10000; i += 1000)
  {
    if (N <= i) {
      cout << i - N;
      return 0;
    }
  }
}

Measured memory_bytes: 3620
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max_profit = -999999999;
		long prev = 1000000001;
		
		int N = sc.nextInt();
		long[] R = new long[N];
		for (int i = 0; i < N; i++) {
			R[i] = sc.nextLong();
		}
		
		for (int i = 0; i < N; i++) {
			if (prev <= R[i]) {
				continue;
			}
			for (int j = i+1; j < N; j++) {
				long tmp = R[j] - R[i];
				max_profit = Math.max(max_profit, tmp);
			}
			prev = R[i];
		}
		
		System.out.println(max_profit);
	}
}

Measured memory_bytes: 99244
import math
(a, b, C) = [float(i) for i in input().split()]
S = 0.5 * a * b * math.sin(math.radians(C))
c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(C)))
print("%8f" %(S))
print("%8f" %(a + b + c))
print("%8f" %(S / a * 2))

Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

ll tollll(string b){
	ll res=0;
	fore(i,0,SZ(b)){
		if(b[i]=='.')continue;
		res*=10;
		res+=b[i]-'0';
	}
	return res;
}

int main(){FIN;
	ll a; cin>>a;
	string b; cin>>b;
	cout<<a*tollll(b)/100;
	
	return 0;
}

Measured memory_bytes: 3652
import heapq
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort()

red = P[:X]
blue = Q[:Y]
heapq.heapify(red)
heapq.heapify(blue)

while R:
    white = R.pop()
    if red[0] < blue[0] and red[0] < white:
        heapq.heappushpop(red, white)
    elif red[0] >= blue[0] and blue[0] < white:
        heapq.heappushpop(blue, white)
    else:
        break

ans = sum(red) + sum(blue)
print(ans)

Measured memory_bytes: 23456
R, G, B = list(map(int, input().split()))
K = int(input())

while G <= R and K > 0:
    G *= 2
    K -= 1
while B <= G and K > 0:
    B *= 2
    K -= 1
if B > G > R:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9180
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#define INF 1000000000//INF=∞
using namespace std;
typedef pair<int, int> P;//firstは最短距離,secondは頂点番号

const int MAX_M = 100;

struct edge {
  int to, cost;
  //edge() : to(0), cost(0) {}
  //edge(int to, int cost) : to(to), cost(cost) {}
};
int V;//頂点の数

vector<vector<edge> > time_graph(MAX_M); //頂点間の距離情報(隣接リスト)
vector<vector<edge> > cost_graph(MAX_M);

vector<vector<int> > time_ds(MAX_M);
vector<vector<int> > cost_ds(MAX_M);

int dijkstra(vector<vector<edge> >& G, vector<vector<int> >& ds, int s, int g){
  if (!ds[s].empty()) return ds[s][g];
  
  priority_queue<P, vector<P>, greater<P> > que;
  vector<int> d(V, INF);//最短距離を記録する配列(∞で初期化しておく)
  d[s] = 0;//頂点sから頂点sへの最短距離は0で確定
  que.push(P(0, s));//距離0,頂点sからスタート

  while(!que.empty()){
    /*処理1*/
    //キューの中で最も頂点sからの距離が近い頂点vとその距離cを取得
    P p = que.top();
    que.pop();
    int v = p.second, c = p.first;

    /*処理2*/
    //頂点vの最短距離がすでに確定していたらcontenue
    if(d[v] < c)
      continue;

    /*処理3*/
    //頂点vの最短距離が既に確定していなければ頂点vへの最短経路はcで確定
      d[v]=c;

    /*処理4*/
    //頂点vから移動しうる頂点とその距離をキューに入れる
    for(int i = 0; i < G[v].size(); i++){
      //頂点vはG[v].size()個の行き先を持つ
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        que.push(P(d[v] + e.cost, e.to));
      }
    }
  }
  ds[s] = d;
  return d[g];//頂点gへの最短距離を返す
}

int main() {
  int n, m;
  while (cin >> n >> m, n || m) {
    V = m;

    for (int i = 0; i < MAX_M; i++) {
      time_graph[i].clear();
      time_ds[i].clear();
      cost_graph[i].clear();
      cost_ds[i].clear();
    }

    for (int i = 0; i < n; i++) {
      int a, b, time, cost;
      cin >> a >> b >> time >> cost;
      a--; b--; // 0-indexedにする
      edge e1,e2,e3,e4;
      e1.to = e3.to = b; e1.cost = e2.cost = time;
      e2.to = e4.to = a; e3.cost = e4.cost = cost;
      time_graph[a].push_back(e1);
      time_graph[b].push_back(e2);
      cost_graph[a].push_back(e3);
      cost_graph[b].push_back(e4);
    }

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;
      p--; q--;
      if (p > q) swap(p, q);
      if (r == 0)
        cout << dijkstra(time_graph, time_ds, p, q) << endl;
      else
        cout << dijkstra(cost_graph, cost_ds, p, q) << endl;
    }
  }
}

Measured memory_bytes: 1188
N = int(input())
A = [int(x) for x in input().split()]
k = N//2
all = sum(A)
ans0 = all
for i in range(k):
    ans0 -= A[1+2*i]*2
print(ans0,end=' ')
last = ans0
for i in range(N-2):
    last = A[i]*2-last
    print(last,end=' ')
print(A[-1]*2-ans0)


Measured memory_bytes: 63984
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  ans <- sum . map snd . take n . filter (even . fst) . zip [1..2*n] . take (2*n) . sortBy (\x y -> compare y x) . map read . words <$> getLine
  print ans

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

bool is_prime(long long n){
  if(n==1) return false;
  long long m = sqrt(n);
  for (long long i = 2; i <= m; i++) if(n%i==0) return false;
  return true;
}

int main(){
  long long x;
  cin >> x;

  while(!is_prime(x)) x++;
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    int sum = 0;
    rep(i,0,N){
        cin >> V[i];
        sum += V[i];
    }
    int mini = INF,ind = 0;
    rep(i,0,N){
        int dif = abs(sum - V[i] * N);
        if(dif < mini){
            mini = dif;
            ind = i;
        }
    }   
    cout << ind << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=1000005;
int n,f[N],fl,ans;
char s[N];
void init(){
	For(i,1,19) For(j,1,(N-1)>>i) ++f[j<<i];
	For(i,1,N-1) f[i]+=f[i-1];
	//cout<<f[1]<<' '<<f[2]<<' '<<f[3]<<endl;//endl;
}
bool check(int x,int y){
	return f[x]==f[y]+f[x-y];
}
int main(){
	init();
	scanf("%d%s",&n,s+1);
	For(i,1,n) s[i]-='1';
	For(i,1,n) if (s[i]==1) fl=1;
	if (!fl) For(i,1,n) s[i]/=2;
	For(i,1,n)
		if (check(n-1,i-1)){
			//cout<<i<<endl;
			ans=(ans+s[i])&1;
		}
	if (!fl) ans*=2;
	printf("%d\n",ans);
}
/*
1231
112
01
1
00002
0002
220
02
2
*/

Measured memory_bytes: 5120
#include <stdio.h>

int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0) break;
    for(j=0; j<H; j++){
      for(i=0; i<W; i++){
	if(i==0 || i==W-1) printf("#");
	else if(j==0 || j==H-1) printf("#");
	else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define inf 1e12
typedef long long ll;

using namespace std;
ll mini = inf;
string s;
ll x;
string ans;
void perm(string t, int bit, int node, int d) {
    if (node == d) {
        ll b = stoll(t);
        ll p = abs(x-b);
        ll q = abs((ll)pow(10,d)-p);
        ll a = max(p,q);
        if (a < mini) {
            mini = a, ans = t;
        }
        else if (a == mini) {
            mini = min(a, mini);
            if (b < stoll(ans)) ans = t;
        }
        return;
    }
    for (int i = 0; i < 10; i++) {
        if (~bit & 1<<i) {
            char c = '0'+i;
            string y = t+c;
            perm(y, bit|1<<i, node+1, d);
        }
    }
}

int main(void) {
    cin >> s;
    x = stoll(s);
    string t;
    int d = s.size();
    perm(t,0,0,d);
    cout << ans << endl;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
typedef long long ll;
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define Fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
const int N=1e5+5;

int A[N];
ll res[N];

 int main()
 {
        int n;
        scanf("%d",&n);
        F(i,1,n) scanf("%d",&A[i]);
        A[n+1]=0;
        A[0]=0;

        ll sm=0;
        int x=0;
        F(i,1,n) sm+=abs(x-A[i]), x=A[i];
        sm+=abs(x);

        F(i,1,n) res[i]=sm+(abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i+1]-A[i]));

        //printf("(%d)\n",abs(A[n-1]-A[n+1]));
        //printf("|%d %d %d|\n",(abs(A[n-1]-A[n+1]),abs(A[n-1]-A[n]),abs(A[n+1]-A[n])));

        F(i,1,n) printf("%lld\n",res[i]);
 }

Measured memory_bytes: 2432
N = input()
if len(N)%2 == 0:
  a = N[:len(N)//2]  
  b = N[len(N)//2:]
  b = b[::-1]
elif len(N)%2 == 1:
  a = N[:len(N)//2+1]  
  b = N[len(N)//2:]
  b = b[::-1]
t = 0
#print(a)
#print(b)
for i in range(len(a)):
  if a[i] != b[i]:
    t+=1
print(t)

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n[3];
	for(int i=0;i<3;i++){
		cin >> n[i];
	}
	sort(n, n+3);
	cout << n[0]*n[1]/2 << endl;
	return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    ll ans=(1900*m+100*(n-m))*(1<<m);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

int n;

long long int y;

scanf("%d %lld",&n,&y);



int a,b;

int d;

for(a=0;a<=n;a++){

for(b=0;b<=n;b++){

 d=y-10000*a-5000*b;

 if(d>=0 && d==(n-a-b)*1000){

  printf("%d %d %d\n",a,b,n-a-b);

  return 0;

 }

}}

printf("-1 -1 -1\n");



return 0;}

Measured memory_bytes: 128
import math
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
      X = K / i
      Y = math.log(X,2)
      if Y * 10 % 10 == 0.0:
        Y_int = int(Y)
      else:
        Y_int = int(Y) + 1
      if i < K:
        Z = 1 / N * (0.5 ** Y_int)
        ans += Z
      else:
        ans += 1 / N

print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int sum = 0;
  
  rep(i,N) {
    cin >> a[i];
    sum += a[i];
  }
  
  int mini = sum;
  int prefix_sum = 0;
  rep(i,N) {
    prefix_sum += a[i];
    mini = min(mini, abs(prefix_sum - (sum-prefix_sum)));
  }
  
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int deta[10000][1000];

int main(){
	int n,m;
	while(scanf("%d%d", &n, &m),n||m){
		rep(i,10000) rep(j,1000) deta[i][j] = 0;
		int r;
		scanf("%d", &r);
		rep(i,r){
			int a,b,c,d;
			scanf("%d%d%d%d", &a, &b, &c, &d);
			a -= 540;
			c--;
			if(d == 1){
				deta[c][a]++;
			} else{
				deta[c][a]--;
			}
		}
		rep(i,10000){
			for(int j = 1; j < 1000; j++){
				deta[i][j] += deta[i][j-1];
			}
		}
		int q;
		scanf("%d", &q);
		rep(i,q){
			int a,b,c;
			int cnt = 0;
			scanf("%d%d%d", &a, &b, &c);
			a -= 540; b -= 540; c--;
			for(int j = a; j < b; j++){
				if(deta[c][j]) cnt++;
			}
			printf("%d\n", cnt);
		}
	}
}

Measured memory_bytes: 40248
#include<stdio.h>

int selectionSort(int*, int);

int main()
{
  int a[100];
  int i, N, swapcnt;

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

  swapcnt = selectionSort(a, N);

  for(i=0;i<N;i++)
    {
      if(i)printf(" ");
      printf("%d", a[i]);
    }
  printf("\n%d\n", swapcnt);
  
  return 0;
}

int selectionSort(int* a, int N)
{
  int i, j, cnt=0, num, minj, flag;

  for(i=0;i<=N-1;i++)
    {
      minj = i;
      flag = 0;
      for(j=i;j<=N-1;j++)
	{	  
	  if(a[j]<a[minj])
	    {
	      minj = j;
	      flag = 1;
	    }
	}
      if(flag)
	{
	  num = a[i]; a[i] = a[minj]; a[minj] = num;
	  cnt++;
	}
    }
  
  return cnt;
}



Measured memory_bytes: 2128
/*input
frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie() , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 200900
#define INF 0x3f3f3f3f

string s;
int nxt[MAX] , dp[MAX];
PII from[MAX];
int32_t main(){
    IOS;
    cin >> s;
    reverse(ALL(s)) , s = " " + s;
    REP(i , 0 , 26) nxt[i] = 0;
    REP(i , 1 , s.size()) dp[i] = INF;
    REP(i , 1 , s.size()){
        REP(j , 0 , 26){
            if(dp[nxt[j]] + 1 < dp[i]){
                dp[i] = min(dp[i] , dp[nxt[j]] + 1);
                from[i] = mp(nxt[j] , j);
            }
        }
        nxt[s[i] - 'a'] = i;
    }
    int sml = INF , id;
    RREP(i , 25 , 0){
        if(dp[nxt[i]] <= sml) sml = dp[nxt[i]] , id = i;
    }
    cout << char('a' + id);
    id = nxt[id];
    while(id != 0){
        cout << char('a' + from[id].B);
        id = from[id].A;
    }cout << endl;
    return 0;
}

Measured memory_bytes: 2896
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
 
using namespace std;
 
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
 
int x[5];
 
int main() {
	int id = -1;
	for(int i = 0; i < 5; ++i) {
		cin >> x[i];
		if(x[i] == 0) id = i+1;
	}
	cout << id;
	
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(void)
{
	int a,b,c,i;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b && b==c) printf("1\n");
	else if(a==b || a==c || c==b) printf("2\n");
	else printf("3\n");
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict


def solve(n, aaa):
    fff = aaa.copy()
    for i in range(n):
        fff[i] -= i
    ans = 0
    count = defaultdict(int)
    for i in range(n - 1, -1, -1):
        ans += count[-i - aaa[i]]
        count[fff[i]] += 1
    return ans


n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))


Measured memory_bytes: 63660
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin>>N;
  for(int i=0;i<25;i++){
    for(int j=0;j<15;j++){
      int total=4*i+7*j;
      if(total==N){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    int[] lst = new int[6];
    
    void shake(char x){
        switch (x){
            case 'W':
                lst = new int[]{lst[2],lst[1],lst[5],lst[0],lst[4],lst[3]};break;
            case 'S':
                lst = new int[]{lst[4],lst[0],lst[2],lst[3],lst[5],lst[1]};break;
            case 'E':
                lst = new int[]{lst[3],lst[1],lst[0],lst[5],lst[4],lst[2]};break;
            case 'N':
                lst = new int[]{lst[1],lst[5],lst[2],lst[3],lst[0],lst[4]};break;
        }
    } 
    
    int rightCheck(int top ,int front){
        
        for(int i=0;i<3;i++){
            if(top==lst[0])break;
            shake('W');
        }
        for(int i=0;i<3;i++){
            if(top==lst[0])break;
            shake('S');
        }
        
        int[] x = {1,2,4,3}; int y=0 ;
        for(int i=0;i<4;i++){
            if(lst[x[i]] == front) y=x[(i+1)%4];
        }
        return this.lst[y];
    }
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        Main dice = new Main();
        for(int i=0;i<6;i++){
            dice.lst[i]=sc.nextInt();
        }
        
        int n=sc.nextInt();
        
        for(int i=0;i<n;i++){
            System.out.println(dice.rightCheck(sc.nextInt(),sc.nextInt()));
        }
    }
}


Measured memory_bytes: 26256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
#define N_MAX 2000005
typedef pair<ll, ll> P;


ll cnt2[N_MAX];

void init(){
    cnt2[0] = 0;
    for(int i = 1; i < N_MAX; i++){
        int cur = 0;
        int j = i;
        while(j%2 == 0){
            j /= 2;
            cur++;
        }
        cnt2[i] = cnt2[i-1]+cur;
    }
}


ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ll a = cnt2[n]-cnt2[n-r];
      ll b = cnt2[r];
      if(a > b){
          ans = 0;
      }else{
          ans = 1;
      }
  }
  return ans;
}

int a[1000000];
int b[1000000];
int cnt[3];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    init();
    for(int i = 0; i < N; i++){
        char c;
        cin >> c;
        a[i] = c-'0';
    }
    for(int i = 0; i < N-1; i++){
        b[i] = abs(a[i+1]-a[i]);
        cnt[b[i]]++;
    }
    if(N == 2){
        cout << b[0] << endl;
        return 0;
    }
    N--;
    if(cnt[1] == N){
        cout << 0 << endl;
    }else if(cnt[1] != 0){
        int sum = 0;
        for(int i = 0; i < N; i++){
            sum += b[i]*comb(N-1, i);
            sum %= 2;
        }
        if(sum%2 == 0){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
    }else{
        for(int i = 0; i < N; i++) b[i] /= 2;
        int sum = 0;
        for(int i = 0; i < N; i++){
            sum += b[i]*comb(N-1, i);
            sum %= 2;
        }
        if(sum%2 == 0){
            cout << 0 << endl;
        }else{
            cout << 2 << endl;
        }
    }
}

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

using namespace std;

int main () {
    int n; cin >> n;
    string s, t;
    cin >> s >> t;

    string ans = "";
    for (int i = 0; i < n; i++) {
        ans += s[i];
		ans += t[i];
    }

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

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

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

Measured memory_bytes: 384
/* Jai Shree Ram
ॐ नमो भगवते वासुदेवाय नमः*/

#include <bits/stdc++.h>
#define endl "\n"
#define FIXED_FLOAT(x,pres) std::fixed <<std::setprecision(pres)<<(x)
#define pb push_back
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;

template <typename T>
class Range {
  public:
    Range(const T& start, const T& stop, const T& step) : start_{start}, stop_{stop}, step_{step} {
        if (step_ == 0) {
            throw std::invalid_argument("Range step argument must not be zero");
        } else {
            if ((start_ > stop_ && step_ > 0) || (start_ < stop_ && step_ < 0)) {
                throw std::invalid_argument("Range arguments must result in termination");
            }
        }
    }
    
    class iterator {
      public:
        typedef std::forward_iterator_tag iterator_category;
        typedef T value_type;
        typedef T& reference;
        typedef T* pointer;

        iterator(value_type value, value_type step, value_type boundary) : value_{value}, step_{step},
                                                                           boundary_{boundary},
                                                                           positive_step_(step_ > 0) {}
        iterator operator++() { value_ += step_; return *this; }
        reference operator*() { return value_; }
        const pointer operator->() { return &value_; }
        bool operator==(const iterator& rhs) { return positive_step_ ? (value_ >= rhs.value_ && value_ > boundary_)
                                                                     : (value_ <= rhs.value_ && value_ < boundary_); }
        bool operator!=(const iterator& rhs) { return positive_step_ ? (value_ < rhs.value_ && value_ >= boundary_)
                                                                     : (value_ > rhs.value_ && value_ <= boundary_); }
        
      private:
        value_type value_;
        const T step_;
        const T boundary_;
        const bool positive_step_;
    };
    
    iterator begin() const {
        return iterator(start_, step_, start_);
    }
    
    iterator end() const {
        return iterator(stop_, step_, start_);
    }
  
  private:
    const T start_;
    const T stop_;
    const T step_;
};

template <typename T>
Range<T> range(const T& stop) {
    return Range<T>(T{0}, stop, T{1});
}

template <typename T>
Range<T> range(const T& start, const T& stop) {
    return Range<T>(start, stop, T{1});
}

template <typename T>
Range<T> range(const T& start, const T& stop, const T& step) {
    return Range<T>(start, stop, step);
}
/*-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------*/
void solve(){
    int n;
    cin >> n;
    if(n == 1) cout << 0;
    else  cout << 1;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
        // cout<< endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
char x[200001];
int main(){
    scanf("%s",x);
    int h=0,minh=0;
    for(int i=0;x[i]!='\0';i++){
        if(x[i]=='S')h++;
        else {
            h--;
            if(h<minh)minh=h;
        }
    }
    printf("%d",-2*minh);
    return 0;
}

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

char a[102][102];
int h,w,ans;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
const char c[] = {'#','*','@'};

void dfs(int i,int j,int k)
{
    a[i][j]='.';
    for(int di=0;di<4;di++){
        int x=i+dx[di],y=j+dy[di];
        if(a[x][y]==c[k]) dfs(x,y,k);
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    while(cin>>h>>w&&h){
        for(int i=0;i<=w+1;i++) a[0][i]=a[h+1][i]='.';
        for(int i=0;i<=h+1;i++) a[i][0]=a[i][w+1]='.';
        for(int i=1;i<=h;i++)
            for(int j=1;j<=w;j++)
                cin>>a[i][j];
        ans=0;
        for(int i=0;i<3;i++)
            for(int j=1;j<=h;j++)
                for(int k=1;k<=w;k++)
                    if(a[j][k]==c[i]) {dfs(j,k,i);ans++;}
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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

long long int a[3][100001];

struct mise {
	int number;
	string name;
	int value;
};

bool biggerthan(mise a, mise b) {
	if (a.name != b.name)  return a.name < b.name;
	return a.value > b.value;
}

int main() {
	int n;
	cin >> n;
	double a;
	string s;
	long double cnt = 0.0000;
	for (int i = 0; i < n; i++) {
		cin >> a >> s;
		if (s == "BTC") {
			cnt += a * 380000.0;
		}
		else {
			cnt += a;
		}
	}    cout << fixed << setprecision(10) << cnt << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
const constexpr ll INF = 1LL<<55;
ll solve() {
	var(int, n);
	vec(ll, a, n);
	map<ll, vll> m;
	map<ll, ll> len_m;
	ll cnt = 0;
	rep(i, 0, n) {
		cnt += a[i];
		m[cnt].eb(i);
		++len_m[cnt];
	}
	each(b, m) {
		m[b.fi].eb(INF);
	}
	ll ans = 0;
	cnt = 0;
	rep(i, 0, n) {
		if (m.find(cnt) != m.end()) {
			ans += len_m[cnt] - (lower_bound(all(m[cnt]), i) - m[cnt].begin());
		}
		cnt += a[i];
	}
	return ans;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 36224