akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)

//unionfind
//init: union_find name(size)

class union_find{
private:
    //根にはグループの要素数に―1をかけたもの、それ以外には根の値
    //初期値は-1
    vector<int> uni;
public:
    //Constructer
    //uniを必要なサイズで初期化する、初期値は―1
    union_find(int unisize) : uni(unisize,-1){}

    //引数aの根を求める、なければaを根として返す
    int root(int a){
        if(uni[a] < 0) return a;
        return uni[a] = root(uni[a]);  
    }

    //頂点aとbを繋ぐ関数unite
    //戻り値：
    //  元々同じグループであればfalse
    //  連結に成功すればtrue
    bool unite(int a, int b){
        //a, bにそれぞれが属するグループの根を入れる
        //uni[a], uni[b]がa, bがそれぞれが属するグループのサイズになる
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a,b); //bの方を大きいものにする
        uni[a] += uni[b];
        uni[b] = a; //大きい方のグループに属するものの親を小さいものの根にする(rootが高速で動くようになる)
        return true;
    }
    //頂点aとbが同じグループかを調べる
    bool isConnected(int a, int b){
        return root(a) == root(b);
    }
    //頂点aを含むグループの頂点数を調べる
    int unisize(int a){
        return -uni[root(a)];
    }
};

int main(){
    int n,m; cin >> n >> m;
    union_find graph(n+1);
    int x,y,z;
    int ans = n;
    rep(i,m){
        cin >> x >> y >> z;
        if(graph.unite(x,y)) ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  char n;
  int a,b,c;cin>>a>>n>>b>>n>>c;
  if(b >= 5){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    s = list(input())
    sum = 0
    for i in s:
        I = int(i)
        sum += I
    if sum % 9 == 0:
        print('Yes')
    else:
        print('No') 

    

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 10632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define deb(x) cout<<#x<<" "<<x<<"\n"
using namespace std;
string s1,s2,u;
int x1,x2;

int main(){
    int n;
    cin>>n;
    set<int>s;
    rep(i,n){
        int t;
        cin>>t;
        s.insert(t);
    }
    if(s.size()==n)cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 9600
/*
ID: garvits2 
TASK: ride
LANG: C++14                 
*/
#include <bits/stdc++.h>

using namespace std;
int arr[100001];
int main(){
	string s;
	cin >> s;
	int x;
	x = s.size();
	if(s[x-1] != 's'){
		cout << s << "s" << endl;
	}
	else{
		cout << s << "es" << endl;
	}
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int a[2][n];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int sum[2][n];
  sum[0][0] = a[0][0];
  for (int i = 1; i < n; i++) {
    sum[0][i] = sum[0][i-1]+a[0][i];
  }
  int max;
  sum[1][0] = sum[0][0]+a[1][0];
  for (int i = 1; i < n; i++) {
    max = sum[0][i];
    if (sum[1][i-1] > max) {
      max = sum[1][i-1];
    }
    sum[1][i] = max+a[1][i];
  }
  printf("%d\n", sum[1][n-1]);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int		main(void)
{
	string s;

	cin >> s;
	sort(all(s));
	if (s == "abc")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

int main() {
    int N;
    vector<string> str(10);
    str[0] = "0111111";
    str[1] = "0000110";
    str[2] = "1011011";
    str[3] = "1001111";
    str[4] = "1100110";
    str[5] = "1101101";
    str[6] = "1111101";
    str[7] = "0100111";
    str[8] = "1111111";
    str[9] = "1101111";

    while (cin >> N, N != -1) {
        int s;
        string start = "0000000";
        while (N--) {
            cin >> s;
            for (int i = 0; i < 7; i++) {
                if (str[s][i] == '1') {
                    if (start[i] == '1') cout << '0';
                    else cout << '1';
                } else {
                    if (start[i] == '0') cout << '0';
                    else cout << '1';
                }
            }
            cout << endl;
            start = str[s];
        }
    }

    return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define repd(i,a,b) for (int i=(a);i<(b);i++)
typedef long long ll;
using namespace std;
// 最大公約数、最小公倍数
ll gcd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
    int n;cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    ll ans = gcd(a[0],a[1]);
    rep(i,n-1){
        ans = gcd(ans,a[i+1]);
    }
    cout << ans << endl;
}

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

int main(void){
    int Q;
    cin >> Q;
    
    for(int q = 0;q < Q;q++){
        string x,y;
        cin >> x >> y;
        
        int dp[x.size()+1][y.size()+1];
        for(int i = 0;i < x.size()+1;i++){
            for(int j = 0;j < y.size()+1;j++){
                dp[i][j] = 0;
            }
        }
        
        for(int i = 0;i < x.size();i++){
            for(int j = 0;j < y.size();j++){
                if(x[i] == y[j]){
                    dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
                }
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j+1]);
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i+1][j]);
            }
        }
        cout << dp[x.size()][y.size()] << endl;
    }
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

int a, b, c, d;
int e[200];

int main() {
	
	cin >> a >> b >> c >> d;
	for(int i = a + 1; i <= b; i++) {
		e[i]++;
	}

	for(int i = c + 1; i <= d; i++) e[i]++;

	int cnt = 0;
	for(int i = 0; i <= 100; i++) if(e[i] == 2) cnt++;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, p; cin >> n >> p;
	int ans = 1;
	map<int, int>mp;
	for (int i = 2; i <= sqrt(p); i++) {
		if (!prime(i))continue;
		while (p%i == 0) {
			mp[i]++;
			p /= i;
		}
		ans *= pow(i, mp[i] / n);
	}
	if (p != 1)mp[p] = 1;
	ans *= pow(p, mp[p] / n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
//#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000
#define N_max 100

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

long int check(long int sum, long int ans, vector<int> T, int N, bool pre_pm) {

    for(int i = 0; i < N; i ++) {
        if(pre_pm) {
            sum += T.at(i);
            while (0 <= sum) {
                sum--;
                ans++;
            }
            pre_pm = false;
        } else {
            sum += T.at(i);
            while (sum <= 0 ) {
                sum++;
                ans++;
            }
            pre_pm = true;
        }
    }
    return ans;
}
 
int main()
{
    int N;
    vector<int> T;

    cin >> N;

    for(int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        T.push_back(tmp);
    }

    long int ans = 0;   
    long int sum = 0;

    bool pre_pm;

    cout << min(check(sum, ans, T, N, true), check(sum, ans, T, N, false)) << endl;

    return 0;
}


Measured memory_bytes: 1528
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
//作者：中国江苏南京朱泽齐
int n,m;
char A[51][51], B[51][51];
bool check(int x, int y) {
	for(int i=0;i<m;i++) {
		for(int j=0;j<m;j++){
			if(A[x+j][y+i]!=B[j][i]){
				return false;
			}
		}
	}
	return true;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>A[j][i];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			cin>>B[j][i];
		}
	}
	
	for(int y=0;y<=n-m;y++){
		for(int x=0;x<=n-m;x++){
			if(check(x,y)){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=5e5+5;
ll n,a[N],c[65],m=1e9+7;

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,0,n-1)
{
	cin>>a[i];
	rep(j,0,60)
	{
		ll x=(1ll<<j);
		if(a[i]&x)
		c[j]++;
	}
}
ll ans=0;
rep(i,0,60)
{
	ll x=(1ll<<i);
	x%=m;
	ll cc=(c[i]*(n-c[i]))%m;
	ans=(ans+cc*x)%m;
}
ol(ans);
return 0;
}



Measured memory_bytes: 2560
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>
#define MAX_V 2000

int
main(int argc, char** argv)
{
	bool f[MAX_V] = { true };
	int n, q;
	int x;
	int i, j;

	f[0] = true;
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%d", &x);
		for (j = MAX_V - x; j >= 0; --j)
		{
			if (f[j])
				f[j + x] = true;
		}
	}

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d", &x);
		printf("%s\n", f[x] ? "yes" : "no");
	}

	return 0;
}

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

while True:
	H, W = map(int, input().split())
	if (not H) and (not W):
		break

	for i in range(H):
		for j in range(W):
			if ((not i % 2) and j % 2) or (i % 2 and (not j % 2)):
				print('.', end='')
			else:
				print('#', end='')
		print()
    
	print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define mm 1000000007
#define ll long long
using namespace std;
bool valid(int x,int y,int n1,int n2){
  if(x>0&& y> 0&&x<=n1&&y<=n2)
  return true;

  return false;
}
string helper(vector<vector<int>>&dp,string &a,string &b,int x,int y){
  if(!valid(x,y,a.size(),b.size()))
  return "";
  if(a[x-1]==b[y-1]){
    return helper(dp,a,b,x-1,y-1)+a[x-1];
  }else{
     string curr;
        if(dp[x-1][y]>=dp[x][y-1]){
          curr=helper(dp,a,b,x-1,y);
        }else{
          curr=helper(dp,a,b,x,y-1);
        }
        return curr;
  }
}
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
  int n1=s.size();
  int n2 = t.size();
vector<vector<int>>dp(n1+1,vector<int>(n2+1,0));
  loop(i,1,n1+1){
    loop(j,1,n2+1){
      if(s[i-1]==t[j-1])
      dp[i][j]=1+dp[i-1][j-1];
      else
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
     }
    }
     string r= helper(dp,s,t,n1,n2);
     cout<<r;
}


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

int main() {
  string s;cin>>s;
  vector<int>vec(26);
  rep(i,s.size()){
    vec[s[i]-'a']++;
  }
  rep(i,26){
    if(vec[i]%2==1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

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

int main(){
    int A,B;
    string S,T,U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S==U) A -= 1;
    else if(T==U) B -= 1;
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define N 100

void push(int);
int pop(void);
int S[N],top;

int main(){
  char A[N];
  int k,a,b;

  top=0;

  while(scanf("%s",A)!=EOF){

    if(atoi(A)!=0){
      k=atoi(A);
      push(k);
    }

    else{
      a=pop();
      b=pop();
      if(A[0]=='+')push(a+b);
      else if(A[0]=='-')push(b-a);
      else if(A[0]=='*')push(a*b);
    }
    
  }


  printf("%d\n",S[top]);

  return 0;
}

int pop(void){
  int x;
  x=S[top];
  top--;
  return x;
}

void push(int a){
  top++;
  S[top]=a;
}

Measured memory_bytes: 2716
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010],b[100010],c[100010],ans=1;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    b[0]=a[0];
    rep2(i,1,n){
        b[i]=gcd(a[i],b[i-1]);
    }
    c[n-1]=a[n-1];
    for(ll i=n-2;i>=0;i--){
        c[i]=gcd(a[i],c[i+1]);
    }
    rep(i,n){
        if(i==0){
            ans=max(ans,c[i+1]);
        }
        else if(i==n-1){
            ans=max(ans,b[i-1]);
        }
        else{
            ans=max(ans,gcd(b[i-1],c[i+1]));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
  int N, K, length[50], i, j, save, sum = 0;
  scanf("%d %d", &N, &K);
  for(i=0; i<N; i++) scanf("%d",&length[i]);
  for(i=0; i<N; i++){
    for(j=i+1; j<N; j++){
      if(length[i] < length[j]){
        save = length[i];
        length[i] = length[j];
        length[j] = save;
      }
    }
  }
  for(i=0; i<K; i++) sum =sum + length[i];
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int n,k;
	cin>>n>>k;
	map<int,bool> m;
	for(int i=1;i<=k;i++){
		int d;
		cin>>d;
		for(int j=1;j<=d;j++){
			int c;
			cin>>c;
			if(!m[c]) n--,m[c]=true;
		}
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 3592
import scala.io.StdIn.readLine

object Main {
  def play(s:String) = {
    val r = (0 until s.length).foldLeft((0,0)){ (x,y) =>
      if(s(y)=='A') (x._1+1,x._2) else (x._1,x._2+1)
    }
    r._1 + " " + r._2
  }

  def main(args:Array[String]) = {
    var s1 = "0"
    while({s1=readLine.trim;s1} != "0") {
      val s2 = readLine.trim
      val s3 = readLine.trim
      println(play(s1.drop(1)+s2(0)))
      println(play(s2.drop(1)+s3(0)))
      val a = s3.drop(1).count(_=='A')
      val b = s3.drop(1).count(_=='B')
      val c = if(a>b) 'A' else 'B'
      println(play(s3.drop(1)+c))
    }
  }

}

Measured memory_bytes: 43448
n = int(input())
c = input()

l = 0
r = n - 1
cnt = 0

while l < r:
    if c[l] == 'W' and c[r] == 'R':
        cnt += 1
        l += 1
        r -= 1
        continue
    else:
        while c[l] != 'W' and l < n - 1:
            l += 1
        while c[r] != 'R' and r > 0:
            r -= 1

print(cnt)


Measured memory_bytes: 9460
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n,m;
int c[111111];
bool b[111111];
int main(void){
  cin >> n >> m;

  for(int i = 0; i < n; i++)
    c[i] = 1;
  memset(b,false,sizeof(b));
  b[0] = true;


  for(int i = 0; i < m; i++){
    int x,y;
    cin >> x >> y;
    x--;y--;
    b[y] |= b[x];
    c[y]++;
    c[x]--;
    if(!c[x])
      b[x] = false;
  }
 
  int ans = 0;
  for(int i = 0; i < n; i++)
    if(b[i])
      ans++;

  cout << ans << endl;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

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 factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
  ll K, N, sum=0;
  ll A[200000];

  scanf("%lld%lld", &N, &K);

  for (int i = 0; i < N; i++)
  {
      scanf("%lld", A+i);
  }
  
  sortdown(A, N);

  for (int i = K; i < N; i++)
  {
      sum += A[i];
  }
  
  printf("%lld", sum);
  
  return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
ll N, M;
int main() {
	cin >> N >> M;
	priority_queue<int>Q;
	int A[100100];
	REP(i, N) {
		cin >> A[i];
		Q.push(A[i]);
	}
	for (int i = 0; i < M; ++i) {
		int p = Q.top();
		Q.pop();
		p /= 2;
		Q.push(p);
	}
	ll sum = 0;
	while (!Q.empty()) {
		int x = Q.top();
		Q.pop();
		sum += x;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1148
const main = (input) => {
  var n = input.trim().split("\n")[0]-0;
  var p = input.trim().split("\n").filter((v,i)=>i>0).map(v=>Number(v));
  var min = p[0]+1;
  var min_i = 1;
  for(var i=0;i<5;i++){
    if(min > p[i]){
      min = p[i];
      min_i = i;
    }
  }
  if(min > n) console.log(5);
  else console.log(Math.ceil(n/min)+4);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 7372
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    *B,=map(int, input().split())

    asum=sum(A)
    bsum=sum(B)
    asmall=0
    bsmall=0
    for a,b in zip(A,B):
        asmall+=(max(0, b-a)+1)//2
        bsmall+=max(0, a-b)
    t=bsum-asum
    print('Yes' if t>=max(asmall,bsmall) else 'No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 40560
PROGRAM DDCCfinals
        implicit none
        integer :: x,y,rank,ans
        integer :: third,second,first
        
        third  = 100000
        second = 200000
        first  = 300000
        ans    = 0
        
        read*,x,y
        
        rank = x
        if( rank==3 ) ans = ans + third
        if( rank==2 ) ans = ans + second
        if( rank==1 ) ans = ans + first
        rank = y
        if( rank==3 ) ans = ans + third
        if( rank==2 ) ans = ans + second
        if( rank==1 ) ans = ans + first
        
        if( x==1 .and. y==1 ) ans = ans + 400000
        
        print*,ans
        
        
      END PROGRAM

Measured memory_bytes: 640
<?php
fscanf(STDIN, '%d', $n);
for ($i  = 0; $i < $n - 1; $i++) {
    fscanf(STDIN, '%d %d', $a, $b);
    $a--;
    $b--;
    $count[$a]++;
    $count[$b]++;
    $g[$a][] = $b;
    $g[$b][] = $a; // 無向グラフの場合
    $a_arr[] = $a;
    $b_arr[] = $b;
}

dfs($a_arr[0], 0);

echo max($count) . PHP_EOL;
for ($i = 0; $i < $n - 1; $i++) {
    echo $color[$a_arr[$i]][$b_arr[$i]] . PHP_EOL;
}

function dfs($v = 0, $par_color)
{
    global $g, $seen, $color;

    $seen[$v] = true;
    if (is_null($g[$v])) return;

    $i = 1;
    foreach ($g[$v] as $to) {
        if ($seen[$to]) continue;
        if ($i === $par_color) $i++;
        // 彩色
        $color[$v][$to] = $color[$to][$v] = $i;
        dfs($to, $i);
        $i++;
    }
}

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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  i64 n, a, b;
  cin >> n >> a >> b;

  if (a > b) cout << 0 << "\n";
  else if (n == 1) {
    if (a != b) cout << 0 << "\n";
    else cout << 1 << "\n";
  }

  else cout << (b - a) * (n - 2) + 1 << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		for(;;){
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if(m == -1 && f == -1 && r == -1)
				break;
			char ans;
			int score = m + f;
			if(score < 30)
				ans = 'F';
			else if(score < 50){
				if(r < 50) ans = 'D';
				else ans = 'C';
			}
			else if(score < 65)
				ans = 'C';
			else if(score < 80)
				ans = 'B';
			else ans = 'A';
			if(m == -1 || f == -1)
				ans = 'F';
			System.out.println(ans);
		}
		
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24320
using System;
using System.Collections.Generic;

namespace AtCoder._20200621
{
    class MixJuice
    {
        public static void Main(string[] args)
        {
            // 文字列配列の入力
            string[] inputStrArray1 = Console.ReadLine().Split(' ');
            int SaleShurui = int.Parse(inputStrArray1[0]);
            int BuyShuruii = int.Parse(inputStrArray1[1]);

            string[] FruitBill = Console.ReadLine().Split(' ');
            List<int> FruitGkList = new List<int>();

            foreach(var x in FruitBill)
            {
                FruitGkList.Add(int.Parse(x));
            }

            FruitGkList.Sort();

            int res = 0;

            for (var a = 0; a < BuyShuruii; a++)
            {
                res += FruitGkList[a];
            }

            Console.WriteLine(res.ToString());
        }
    }
}


Measured memory_bytes: 28188
// Problem: D - Wizard in Maze
// Contest: AtCoder - AtCoder Beginner Contest 176
// URL: https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    auto isValid = [=](int a, int b) {
        return a >= 0 && b >= 0 && a < n && b < m;
    };

    vector<vector<char>> mat(n, vector<char>(m));
    pair<int, int> start, stop;
    cin >> start.first >> start.second;
    cin >> stop.first >> stop.second;

    start.first--;
    stop.first--;
    start.second--;
    stop.second--;

    for (int a = 0; a < n; a++) {
        string ss;
        cin >> ss;
        for (int b = 0; b < m; b++) mat[a][b] = ss[b];
    }

    vector<vector<int>> dist(n, vector<int>(m, 1e9));

    dist[start.first][start.second] = 0;

    deque<int> qx, qy;
    qx.push_back(start.first);
    qy.push_back(start.second);

    vector<pair<int, int>> dirs = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};

    while (!qx.empty()) {
        int x = qx.front();
        int y = qy.front();

        qx.pop_front();
        qy.pop_front();

        for (auto &e : dirs) {
            int newX, newY;
            newX = x + e.first;
            newY = y + e.second;

            if (isValid(newX, newY) && mat[newX][newY] == '.' &&
                dist[newX][newY] > dist[x][y]) {
                dist[newX][newY] = dist[x][y];
                qx.push_front(newX);
                qy.push_front(newY);
            }
        }

        for (int posa = -2; posa <= 2; posa++)
            for (int posb = -2; posb <= 2; posb++) {
                int newX, newY;
                newX = x + posa;
                newY = y + posb;

                if (isValid(newX, newY) && dist[newX][newY] > dist[x][y] + 1 &&
                    mat[newX][newY] == '.') {
                    dist[newX][newY] = dist[x][y] + 1;
                    qx.push_back(newX);
                    qy.push_back(newY);
                }
            }
    }

    if (dist[stop.first][stop.second] == 1e9)
        cout << "-1";
    else
        cout << dist[stop.first][stop.second];

    return 0;
}


Measured memory_bytes: 8196
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	vector<int> c(2 * n);
	rep(i, 0, 2 * n) c[i] = i + 1;
	int m; cin >> m;
	rep(i, 0, m) {
		int k; cin >> k;
		if (k == 0) {
			vector<int> tmp(2 * n);
			rep(j, 0, n) {
				tmp[j * 2] = c[j];
				tmp[j * 2 + 1] = c[n + j];
			}
			c = tmp;
		}
		else {
			vector<int> tmp(2 * n);
			rep(j, 0, k)tmp[2 * n - k + j] = c[j];
			rep(j, k, 2 * n)tmp[j - k] = c[j];
			c = tmp;
		}
	}
	rep(i, 0, c.size()) {
		cout << c[i] << endl;
	}
	return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i))
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(x,v) for(const auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義 #define int long long
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; }
//lambda: [&](int x, int y){return x<y;}

ll calc(ll n,ll x){
    return n/x+1;
}

signed main(void){
    ll a,b,x;cin>>a>>b>>x;
    ll ans=calc(b,x);
    if(a!=0) ans-=calc(a-1,x);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

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

  ll ans=0;
  for(int bit=0;bit<(1<<s.size()-1);bit++){
    ll now=s[0]-'0';
    ll sum=0;
    // cout<<bitset<8>(bit)<<endl;
    for(int i=1;i<s.size();i++){
      int k=1<<(i-1);
      // cout<<k<<endl;
      if((bit&k)!=0){
        sum+=now;
        now=s[i]-'0';
      }else{
        now*=10;now+=s[i]-'0';
      }
      // cout<<"now "<<now<<endl;
    }
    sum+=now;
    // cout<<sum<<endl;
    ans+=sum;
  }
  cout<<ans<<endl;

  return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++)  cin >> A[i];
    int m = 0;

    while(true){
        sort(A.begin(), A.end());
        m = lower_bound(A.begin(), A.end(), 1) - A.begin();
        if(m==N-1) break;

        for(int i=m+1; i<N; i++) A[i] = A[i]%A[m];
    }
    cout << A[m] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int n,q;
    cin >> n >> q;
    queue<pair<string, int>> que;
    for(int i=0; i<n; i++) {
        string s; cin >>s;
        int t; cin >> t;
        auto e = make_pair(s, t);
        que.push(e);
    }
    int time=0;
    while(!que.empty()) {
        auto e = que.front(); que.pop();
        e.second -= q;
        if(e.second<=0) cout<<e.first << " " << time + q + e.second << endl;
        else que.push(e);
        time += min(q, q+e.second);
    }
    return 0;
}



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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if(v[i-1] != i) continue;
        int k = 1;
        for (int j = i+1; j <= n; ++j) {
            if(v[j-1] != i) break;
            k++;
        }
        i += k;
        ans += (k+1)/2;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long inf=0x3f3f3f3f;
int main(){
	string s;
	cin>>s;
	long long n=s.size()-1;
	long long ans=0;
	for(long long i=0;i<(1<<n);i++)
	{
		long long tmp=0;
		bitset<10> b(i);
		for(int j=0;j<=n;j++)
		{
			long long a=s[j]-'0';
			tmp=tmp*10+a;
			if(b.test(j)||j==n)
			{
				ans+=tmp;
				tmp=0;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// PDF解説に倣って。
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,a;
  cin>> n;
  vector<int> index(n);
  for (int i=0; i<n; i++){
    cin>> a;
    index[n-a]=i;
  }
  
  
  int64_t ans=0,num,le,l,r,re;
  multiset<int> s;
  s.insert(-1); s.insert(-1); s.insert(n); s.insert(n);
  for (int i=0; i<n; i++){
    num=index[i];
    auto itr=s.lower_bound(num); //ひょっとするとここの書き方？
    r=*itr++;
    re=*itr--;itr--;
    l=*itr--;
    le=*itr;
    ans+=(n-i)*((l-le)*(r-num)+(num-l)*(re-r));
    s.insert(num);
  }
  cout<< ans << endl;
}
/*TLEは台風のせいではありません*/

Measured memory_bytes: 5376
loop{
    n=gets.to_i;
    exit if n==0;
    [*1..n].map{|i|s,*a=gets.split;t=0;a.map{|b|b=b.to_i;t+=b==0 ? 2*n : b==1 ? -1 : 0};[-t,i,s]}.sort.map{|a|puts a[2]}
}


Measured memory_bytes: 6904
import java.util.Scanner;
class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s=sc.next();
		String sa[]=s.split("/");
		if(Integer.parseInt(sa[0])<=2019&&Integer.parseInt(sa[1])<=4&&Integer.parseInt(sa[2])<=30)
			System.out.println("Heisei");
		else
			System.out.println("TBD");
		}
		}






Measured memory_bytes: 23508
#include <iostream>

using namespace std;
int arr[1001];
int arr2[1001];

int main()
{
    int n,k,Min=9999,c=0,sum=0;
    cin>>n>>k;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(int j=0; j<k; j++)
    {

        for(int i=0; i<n; i++)
        {
            if(arr[i]<=Min)
            {
                Min=arr[i];
                c=i;
            }
        }
        sum=sum+Min;
        arr[c]=99999;
        Min=9999;
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3156
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if((b-a)&1) {
        if(n-b > a-1) {
            a = -a+1;
        } else {
            b = n+n-b+1;
        }
    }
    cout << (b-a)/2 << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
  int h_size, w_size;
  int h, w;
  int answer;
  scanf("%d%d", &h_size, &w_size);
  scanf("%d%d", &h, &w);

  answer
    = h_size * w_size
    - h * w_size
    - h_size * w
    + h * w;

  printf("%d\n", answer);
  return 0;
}


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

using namespace std;
const int nmax = 2e5 + 100;
int a[nmax];
int main() {
//    freopen("in.txt","r",stdin);
    int n; scanf("%d", &n);
    int l = 1;
    long long ans = 0, sum = 0;
    for(int r = 1; r <= n; r++){
        scanf("%d", &a[r]);
        while((sum ^ a[r]) != sum + a[r]) sum ^= a[l], l++;
        sum ^= a[r];
        ans += (r - l + 1);
    }
    printf("%lld\n", ans);
    return 0;


    return 0;
}


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

vector<bool> make_primes(int n) {
	vector<bool> is_prime(n + 1, true);
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= n; ++i) {
		for (int j = i * 2; j <= n; j += i) {
			is_prime[j] = false;
		}
	}
	return is_prime;
}

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

	vector<bool> is_prime = make_primes(100000);
    bool is_like_2017[100001];
	for (int i = 0; i <= 100000; ++i) {
		is_like_2017[i] = is_prime[i] && is_prime[(i + 1) / 2];
	}

    int sum[100002];
	sum[0] = 0;
	for (int i = 0; i <= 100000; ++i) {
		sum[i + 1] = sum[i];
		if (is_like_2017[i]) {
			sum[i + 1]++;
		}
	}

	for (int i = 0; i < n;  ++i) {
		int l, r;
		cin >> l >> r;

		cout << sum[r + 1] - sum[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
N, M, C = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

count = 0
for _ in range(N):
    A = [int(x) for x in input().split()]

    if sum(a * b for a, b in zip(A, B)) + C > 0:
        count += 1
print(count)



Measured memory_bytes: 3060
a, b = map(int, input().split())
if (0 < a):
  res = "Positive"

elif a <= 0 <= b:
  res = "Zero"

else:
  if a == b:
    res = "Positive"
  elif (b-a) % 2 == 1:
    res = "Positive"
  else:
    res = "Negative"
print(res)

Measured memory_bytes: 9064
def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

n=int(input())
ans=0
for i in range(1,n+1):
	for j in range(i,n+1):
		for k in range(j,n+1):
			if i!=j!=k:
				ans+=6*gcd(gcd(i,j),k)
			elif i==j==k:
				ans+=i
			else:
				ans+=3*gcd(gcd(i,j),k)
print(ans)


Measured memory_bytes: 9196
#include <iostream>

int main(void)
{
	using namespace std;
	
	int H,W;
	while(1){
		cin >> H;
		cin >> W;

		if((H==0) && (W==0))	break;

		for(int hy=0; hy<H; ++hy){
			for(int wx=0; wx<W; ++wx){
				if((0<hy && hy<H-1) && (0<wx && wx<W-1))	cout << ".";
				else cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	
	}


	return 0;

}

Measured memory_bytes: 2980
package main

import (
	"fmt"
//	"strconv"
//	"sort"
//	"math"
//	"regexp"
)


var H,W int

func main(){
	fmt.Scan(&H,&W)

	c:=make([]string,H)

	for i:=0;i<H;i++{
		fmt.Scan(&c[i])
	}
	
	for j:=0;j<H;j++{
		for i:=0;i<2;i++{	
			fmt.Println(c[j])
		}
	}
}



Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  double p[4][2],m[2][2],inv[2][2],det,x[2];
  while(cin >>p[0][0]>>p[0][1]>>p[1][0]>>p[1][1]>>p[2][0]>>p[2][1]>>p[3][0]>>p[3][1]){
    for(int i=1; i<4; i++) for(int j=0; j<2; j++) p[i][j]-=p[0][j];
    for(int i=0; i<2; i++) for(int j=0; j<2; j++) m[i][j] = p[1+j][i];
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    inv[0][0] = m[1][1]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[1][1] = m[0][0]/det;
    for(int i=0; i<2; i++) x[i] = inv[i][0]*p[3][0]+inv[i][1]*p[3][1];
    if(x[0]>0 && x[1]>0 && x[0]+x[1]<1) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;

    for (int i = 0; i < K; i++) {
        char last = '\0';
        for (int j = 0; j < N; j += K) {
            // cout << j + i << endl;
            if (T[j + i] == last) {
                T[j + i] = 'x';
            }
            last = T[j + i];
        }
    }
    // cout << T << endl;

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (T[i] == 'r') {
            ans += P;
        } else if (T[i] == 's') {
            ans += R;
        } else if (T[i] == 'p') {
            ans += S;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if (a + b > c + d) {
    cout << "Left" << endl;
  }else if (a + b < c + d) {
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String inStr;
		inStr = inp();
		String[] in;
		in = inStr.split(" ");

		int a = Integer.valueOf(in[0]);
		int b = Integer.valueOf(in[1]);

		if (a < b)
			System.out.println("a < b");
		else if (a > b)
			System.out.println("a > b");
		else
			System.out.println("a == b");

	}

	private static String inp() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}

Measured memory_bytes: 24452
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define int(x) int x; scanf("%d",&x)
#define input(x) scanf("%d",&x)
#define rep(x,n) for(int x = 0; x < n; x++)
#define _br printf("\n")
#define INF 2000000000

vector<pair<int,int> > PathList[100];
int d[100];
bool complete[100];

void dijkstra(int n,vector<pair<int,int> > PathList[]){
    rep(i,n){
        d[i] = INF;
        complete[i] = false;
    }
    d[0] = 0;
    
    int count = 0;
    
    while (count != n) {
        int mind = INF;
        int mindi = 0;
        
        //select
        rep(i,n){
            if (!complete[i] && d[i] < mind) {
                mind = d[i];
                mindi = i;
            }
        }
        
        complete[mindi] = true;
        count++;
        
        //update
        rep(i,PathList[mindi].size()){
            if (PathList[mindi][i].second + d[mindi] < d[PathList[mindi][i].first]) {
                d[PathList[mindi][i].first] = PathList[mindi][i].second + d[mindi];
            }
        }
    }
}


int main(){
    int(n);
    rep(i,n){
        int(k);int(num);
        rep(j,num){
            int(s);int(t);
            PathList[i].push_back(make_pair(s,t));
        }
    }
    
    dijkstra(n,PathList);
    
    rep(i,n){
        printf("%d %d\n",i,d[i]);
    }
    
    return 0;
}

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

int main() {

    int k;
    cin >> k;
    queue<long long> coada;
    for(int i = 1; i <= 9; i++) {
        coada.push(i);
    }
    while(1) {
        long long x = coada.front();
        k--;
        coada.pop();
        if(k == 0) {
            cout << x;
            break;
        }
        for(int i = max(x % 10 - 1, 0LL); i <= min(x % 10 + 1, 9LL); i++) {
            coada.push(x * 10 + i);
        }
    }
    return 0;
}


Measured memory_bytes: 5112