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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N;
vector<int> D;

int
main()
{
  cin >> N;
  REP(i, N) { int tmp; cin >> tmp; D.emplace_back(tmp); }

  SORT(D);

  int ABC = D[N/2-1];
  int ARC = D[N/2];

  if (ABC == ARC) {
    ANS(0);
  } else {
    ANS(ARC - ABC);
  }
  
  return 0;
}


Measured memory_bytes: 892
a = [list(map(int, input().split())) for _ in range(3)]
if a[0][1] - a[0][0] == a[1][1] - a[1][0] == a[2][1] - a[2][0] and a[0][2] - a[0][0] == a[1][2] - a[1][0] == a[2][2] - a[2][0]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif




ll n, k;

// vx[i] : ビットiをxにした時のfの値
ll v0[50];
ll v1[50];


int main(){
	cin >> n >> k;
	
	vector<ll> a(n);
	rep(i,n)
		cin >> a[i];
	
	rep(i,n){
		rep(j,50){
			ll b = 1LL << j;
			if ( a[i] & b )
				v0[j] += b;
			else
				v1[j] += b;
		}
	}
	
	rep(i,50)
		eprintf( "%d: %lld %lld\n", i, v0[i], v1[i] );
	
	vector<ll> dp0(51); // dp0[i] xがi桁以下でf(x)の最大値
	vector<ll> dp1(51); // dp1[i] xがi桁以下 かつx<=(kの下i桁) でf(x)の最大値
	rep(i,50){
		dp0[i+1] = max(v0[i],v1[i]) + dp0[i];
		dp1[i+1] = (k & (1LL<<i))
			? max({
				dp0[i]+v0[i],
				dp1[i]+v0[i],
				dp1[i]+v1[i],
			}) 
			: dp1[i] + v0[i];
	}
	
	cout << dp1[50] << endl;
	
	return 0;
}




Measured memory_bytes: 4032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  string S;
  cin>>S;

  vector<int> rs,ws;
  rep(i,N){
    if(S[i]=='W') ws.push_back(i);
    else rs.push_back(i);
  }

  int ans=0;
  int w=0,r=(int)rs.size()-1;
  while(w<ws.size()&&r>=0){
    if(ws[w]>rs[r]) break;
    ans++;
    w++;
    r--;
  }
  /*if(w<ws.size()) ans+=(int)ws.size()-w;
  if(r>=0) ans+=r+1;*/

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4812
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int b[n];
int ans=0;
    for(int i=1;i<n-1;i++){
        if(A[i-1]<A[i] && A[i]<A[i+1]){
            ans++;
            b[i]++;
        }
        else{
            b[i]=0;
        }
    }
     for(int i=1;i<n-1;i++){
        if(A[i-1]>A[i] && A[i]>A[i+1] && b[i]==0){
            ans++;
        }
    }


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

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 2005;
char s[N][N];
int u[N][N], d[N][N], l[N][N], r[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int h, w;
	cin>>h>>w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin>>s[i][j];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '#'){
				u[i][j] = 0;
				l[i][j] = 0;
			}else{
				u[i][j] = 1 + (i?u[i - 1][j]:0);
				l[i][j] = 1 + (j?l[i][j - 1]:0);
			}
		}
	}
	for(int i = h - 1; i >= 0; i--){
		for(int j = w - 1; j >= 0; j--){
			if(s[i][j] == '#'){
				d[i][j] = 0;
				r[i][j] = 0;
			}else{
				d[i][j] = 1 + ((i + 1 != h)?d[i + 1][j]:0);
				r[i][j] = 1 + ((j + 1 != w)?r[i][j + 1]:0);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] == '#')continue;
			ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
		}
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 66944
#include <iostream>

using namespace std;

int main() {
    int n, l, sum;
    cin >> n >> l;

    if (l >= 0) {
        sum = l * (n - 1) + (n - 1) * n / 2;
    }else{
        if (-l < n){
            sum = l * n + (n - 1) * n / 2;
        } else {
            sum = l * n + (n - 1) * n / 2 - (l + n -1);
        }
    }

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

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

typedef bitset<4010> B;
typedef long long ll;

const ll MOD = 998244353;

ll POW[4002];
void init(){
	POW[0] = 1;
	for(int i = 0 ; i < 4001 ; i ++){
		POW[i+1] = POW[i]*2;
		if(POW[i+1] >= MOD)POW[i+1] -= MOD;
	}
}

int find_last(B x){
	for(int i = 4009 ; i >= 0 ; i --){
		if(x[i])return i;
	}
	return -1;
}

B gcd(B x,B y){
	if(x.none())return y;
	int s = find_last(x);
	int t = find_last(y);
	if(s < t){
		swap(x,y);
		swap(s,t);
	}
	while(y.any()){
		x ^= y<<(s-t);
		s = find_last(x);
		if(s < t){
			swap(x,y);
			swap(s,t);
		}
	}
	return x;
}

int main(){
	init();
	int n;
	B x,a[7];
	cin >> n;
	cin >> x;
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	
	for(int i = 1 ; i < n ; i ++){
		a[0] = gcd(a[0],a[i]);
	}
	
	ll ret = 0;
	int s = find_last(x);
	int t = find_last(a[0]);
	B y; y.reset();
	
	for(int i = s ; i >= t ; i --){
		if(x[i])ret += POW[i-t];
		if(x[i] != y[i])y ^= a[0] << (i-t);
	}
	for(int i = s ; i >= 0 ; i --){
		if(x[i] == y[i]){
			if(i == 0)ret ++;
			continue;
		}
		if(x[i])ret ++;
		break;
	}
	cout << ret%MOD << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.141592653589793
int main(void){
    double a,b,x;
    cin>>a>>b>>x;
    double tt=0.0;
    if(x>(a*a*b)/2.0){
        tt=a/(2.0*(b-(x/(a*a))));
    }else{
        tt=(2.0*x)/(a*b*b);
    }
    double t=atan(tt);
    double deg=90.0-(t*180.0/PI);
    cout<<setprecision(11)<<deg;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(abs,a))
c=0
for i in range(n):
     if a[i]<0:
        c += 1
if c%2==0:
    print(sum(b))
else:
    d=sorted(b)
    print(sum(d)-2*d[0])
    

Measured memory_bytes: 14412
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var res = (int)1e5;
        for (var i = 0; i <= num; i++)
        {
            var re = num - i;
            var ct = 0;
            var ct1 = i / 6;
            while (ct1 > 5) {
                ct += ct1 % 6;
                ct1 /= 6;
            }
            ct += i % 6 + ct1;
            var ct2 = re / 9;
            while(ct2>8)
            {
                ct += ct2 % 9;
                ct2 /= 9;
            }
            ct += re % 9 + ct2;
            res = Min(res, ct);
        }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static string[] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 11220
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N  = scan.nextInt();
        long[] A = new long[N];
        for(int i=0;i<N;++i)A[i]=scan.nextLong();
            long top=-1;
            long ans = 0;
            for(int i=0;i<N;++i){
                if(A[i]!=top+1){
                    if(A[i]>top+1){
                        System.out.println(-1);
                        return;
                    }
                    ans += top;
                }
                top=A[i];
            }
            System.out.println(ans + A[N-1]);
    }
}

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

using namespace std;


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector <long long> a(n+1);
    for (int i=0;i<=n;i++)
        cin >> a[i];

    vector <long long> h(n);
    for (int i=0;i<n;i++)
        cin >> h[i];

    long long ans=0;
    for (int i=0;i<=n;i++)
    {
        if (i>0)
            if (h[i-1]>=a[i])
        {
            h[i-1]-=a[i];
            ans+=a[i];
            a[i]=0;
            continue;
        }
        else
        {
            ans+=h[i-1];
            a[i]-=h[i-1];
            h[i-1]=0;
        }

        if (i<n)
        if (h[i]>=a[i])
        {
            h[i]-=a[i];
            ans+=a[i];
            a[i]=0;
            continue;
        }
        else
        {
            ans+=h[i];
            a[i]-=h[i];
            h[i]=0;
        }
    }

    cout << ans;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define push_back pb
using namespace std;
typedef long long ll;

const int maxn=10;
int T,A[maxn+2],B[maxn+2],C[maxn+2];
int x,y;

bool dfs(int a)
{
    if(a==maxn) return true;
    if(A[a]<B[x-1] && A[a]<C[y-1]) return false;
    else if(A[a]>B[x-1]) B[x++]=A[a];
    else if(A[a]>C[y-1]) C[y++]=A[a];
    return dfs(a+1);
}

int main()
{
    cin>>T;
    while(T--){
        for(int i=0;i<maxn;i++)
            cin>>A[i];
        mem(B,0);
        mem(C,0);
        x=y=1;
        if(dfs(0)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1148
N = int(input())
H = [int(x) for x in input().split()][::-1]

l = 0
r = 0
m = 0
while l < N:
    while r + 1 < N and H[r] <= H[r+1]:
        r += 1
    # H[r] > H[r+1]
    m = max(m, r-l)
    l = r+1
    r = l
print(m)




Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
using namespace std;

long long n, m;
vector<long long> s, t;
long long dp[2005][2005] = {0};

long long solve();

int main() {
  cin >> n >> m;
  s.resize(n);
  t.resize(m);
  for(int i = 0; i < n; ++i) cin >> s[i];
  for(int i = 0; i < m; ++i) cin >> t[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  dp[0][0] = 1;
  for(int i = 0; i <= n; ++i) dp[i][0] = 1;
  for(int i = 0; i <= m; ++i) dp[0][i] = 1;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j) {
      dp[i + 1][j + 1] =
          (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + N) % N;
      if(s[i] == t[j]) dp[i + 1][j + 1] += dp[i][j] % N;
      dp[i + 1][j + 1] %= N;
    }

  return dp[n][m];
}

Measured memory_bytes: 31616
#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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#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 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)

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

#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){
    int N,M; cin >> N >> M;
    int edge[N][N]; REP(i,N)REP(j,N) edge[i][j] = 0;
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }

    int ans = 0;
    VI p(N-1); REP(i,N-1) p[i] = i+1;
    do{
        int from = 0;
        REP(i,N-1){
            if(edge[from][p[i]] == 0) break;
            from = p[i];
        }
        if(from == p[N-2]) ans++;
    }while(next_permutation(p.begin(), p.end()));

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db double
#define lli	long long int
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
int main()
{
	lli n,ans=0,temp,mul=5;
	cin >> n;
	if(n%2!=0)	cout << "0" << endl;
	else
	{
		while(mul<=n)
		{
			temp=n/mul;
			ans+=(temp/2);
			mul=mul*5;
		}
		cout << ans << endl;
	}
	return 0; 
}

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

int main(){
	char s[11];
	scanf("%s", &s);
	int len = strlen(s);
	for(int i=0; i<len; i++){
		int detectB = 0;
		if(s[i]=='B' && i!=0){
			int j=i;
			int k = 1;
			while(s[j]=='B'){
				s[i-k] = 'B';
				k++;
				j++;
			}
			detectB++;
		}
	}
	for(int i=0; i<len; i++){
		if(s[i] != 'B'){
			printf("%c", s[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 3160
def isPrime( x ):
	if 2 == x or 3 == x:
		return True
	if 0 == x%2:
		return False
	i = 3 
	while  i*i <= x:
		if 0 == x%i:
			return False
		i += 1
	return True


n = int( raw_input( ) )
nums = []
i = 0
while i < n:
	nums.append( int( raw_input( ) ) )
	i += 1
cnt = i = 0
for num in nums:
	if isPrime( num  ):
		cnt += 1
	i += 1

print( cnt )

Measured memory_bytes: 4540
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){

	int n,count,tmp;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		count = 0;
		for(int i=1;i <= n; i++){
			tmp = i;
			while(tmp >= 5 && tmp%5  == 0){
				count++;
				tmp /= 5;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 2568
a,b,c=map(int,input().split())
num = 0

while num < 2:
    if a>b :
        i = a
        a = b
        b = i

    if b>c :
        i = b
        b = c
        c = i

    if a > c:
        i = a
        a = c
        c = i
    
    num += 1

print(a , b , c)


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

int main() {
  int N;
  cin >> N;
  
  int total = 0;
  vector<int> W(N);
  for(int i = 0; i < N; i++ ){
    cin >> W.at(i);
    total += W.at(i);
  }
  
  int s1 = 0;
  int ans = 1000000;
  for( int i = 0; i < N; i++ ){
    s1 += W.at(i);
    total -= W.at(i);
    if( s1 < total ){
      ans = min(total-s1, ans);
    }else{
      ans = min(s1-total,ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
input = lambda: sys.stdin.readline().rstrip()

mod = 10**9 + 7


class Factorize(object):

    def __init__(self, maxnum):
        self.primes = self.__smallest_prime_factors(maxnum)

    # 素因数分解する(リスト)
    def factorize_list(self, n):

        fct = []
        while n != 1:
            fct.append(self.primes[n])
            n //= self.primes[n]
        return fct

    # 素因数分解する(辞書)
    def factorize_dict(self, n):
        fct = defaultdict(lambda: 0)
        while n != 1:
            fct[self.primes[n]] += 1
            n //= self.primes[n]
        return fct

    # n以下の最小の素因数を列挙する
    def __smallest_prime_factors(self, n):

        prime = list(range(n + 1))

        for i in range(2, int(n**0.5) + 1):
            if prime[i] != i:
                continue
            for j in range(i * 2, n + 1, i):
                prime[j] = min(prime[j], i)
        return prime


def divmod(x, mod=10**9 + 7):
    return pow(x, mod - 2, mod)


def solve():

    N = int(input())
    A = list(map(int, input().split()))
    fct = Factorize(max(A))

    lcm_dict = defaultdict(lambda: 0)
    for i in range(N):
        d = fct.factorize_dict(A[i])
        for k, v in d.items():
            lcm_dict[k] = max(lcm_dict[k], v)

    lcm = 1
    for k, v in lcm_dict.items():
        lcm *= (k**v)
        lcm %= mod

    ans = 0
    for i in range(N):
        ans += divmod(A[i])
        ans %= mod

    ans *= lcm
    ans %= mod
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 44396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	ll q, a, b;
	cin >> q;
	for (int i = 0;i < q;i++) {
		cin >> a >> b;
		ll ans = 0;
		ll root = (ll)sqrtl(a*b);
		if (a == b) {
			cout << (root - 1) * 2 << endl;
			continue;
		}
		if (root*root >= a * b)ans--;
		if (root*(root + 1) >= a * b)ans--;
		if (a != b)ans--;
		ans += root * 2;
		cout << ans << endl;
	}
	return 0;
}

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


int main() {

    int n;
    cin>>n;

    int64_t m=0,a=0,r=0,c=0,h=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s.at(0)=='M')
          m++;
        else if(s.at(0)=='A')
          a++;
        else if(s.at(0)=='R')
          r++;
        else if(s.at(0)=='C')
          c++;
        else if(s.at(0)=='H')
          h++;
    }

  int64_t cnt=0;
  //5C3=10通りを加算
  //M,A,R
  cnt+=m*a*r;
  //M,A,C
  cnt+=m*a*c;
  //M,A,H
  cnt+=m*a*h;
  //M,R,C
  cnt+=m*r*c;
  //M,R,H
  cnt+=m*r*h;
  //M,C,H
  cnt+=m*c*h;
  //A,R,C
  cnt+=a*r*c;
  //A,R,H
  cnt+=a*r*h;
  //A,C,H
  cnt+=a*c*h;
  //R,C,H
  cnt+=r*c*h;

  cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
ans=0
trend=None
prev=None
for a in A:
    if prev is None:
        ans+=1
    elif prev<a:
        if trend is None:
            trend="plus"
        elif trend=="plus":
            pass
        elif trend=="minus":
            ans+=1
            trend=None
    elif prev>a:
        if trend is None:
            trend="minus"
        elif trend=="plus":
            ans+=1
            trend=None
        elif trend=="minus":
            pass
    elif prev==a:
        if trend is None:
            pass
        elif trend=="plus":
            pass
        elif trend=="minus":
            pass
    prev=a

print ans

Measured memory_bytes: 41644
def f(n) :
    if (n % 2 == 0) :
        return n // 2
    else :
        return 3 * n + 1

def main() :
    # 10^6なので愚直でいいはず。
    s = int(input())
    li = [s]
    loop_count = 1
    while(True) :
        loop_count += 1
        n = f(s)
        if (li.count(n) > 0) :
            print(loop_count)
            return
        else :
            li.append(n)
            s = n

    

main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    vector<ll> x(n);
    For(i,0,n) cin>>x[i];
    ans=1e9;
    For(d,0,101){
        ll cost=0;
        For(i,0,n){
            cost+=(x[i]-d)*(x[i]-d);
        }
        ans=min(ans,cost);
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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


int main() {
  int n;
  cin >> n;
  if(n/100==7||n%10==7||(n-n/100*100)/10==7){
    cout<<"Yes"<<endl;
  }

  else{
    cout<<"No"<<endl;
  }
  
}






Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#define INF 2100000000
#define INVALID -1
using namespace std;
int dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
int absint(int a)
{
	return max(a , - a);
}
int main()
{
	long long int h, w, i, j, k, l,ans=0;
	char s[410][410];
	long long static int kei[410][410], brack[160000 + 10], white[160000 + 10];
	static bool inqueue[410][410];
	queue<pair<int, int> > q;
	cin >> h >> w;
	for (i = 0; i < h; i++)
	{
		cin >> s[i];
	}
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			//cout << s[i][j];
		}
		//cout << endl;
	}
	l = 0;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			if (kei[i][j] == 0)
			{
				q.push(make_pair(i, j));
				kei[i][j] = l++;
				while (q.size())
				{
					pair<int, int> cur, p = q.front();
					q.pop();
					kei[p.first][p.second] = l;
					//inqueue[p.first][p.second] = false;
					for (k = 0; k < 4; k++)
					{
						cur.first = p.first + dx[k];
						cur.second = p.second + dy[k];
						if (0 <= cur.first&&cur.first < h && 0 <= cur.second&&cur.second < w&&inqueue[cur.first][cur.second] == false)
						{
							if (s[p.first][p.second] == '#'&&s[cur.first][cur.second] == '.')
							{
								q.push(cur);
								inqueue[cur.first][cur.second] = true;
							}
							if (s[p.first][p.second] == '.'&&s[cur.first][cur.second] == '#')
							{
								q.push(cur);
								inqueue[cur.first][cur.second] = true;
							}
						}
					}

				}
			}
		}
	}
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
		{
			//cout << kei[i][j];
			if (s[i][j] == '#') brack[kei[i][j]]++;
			else white[kei[i][j]]++;
		}
		//cout << endl;
	}
	for (i = 1; i <= l; i++)
	{
		//printf("%d,%d\n", brack[i], white[i]);
		ans += brack[i]* white[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 2944
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1 for i in range(n)]

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M=[int(i) for i in input().split(" ")]
uf = UnionFind(N)
for i in range(M):
    A,B=[int(i) for i in input().split(" ")]
    uf.union(A-1,B-1)

d={}
for i in range(N):
    root = uf.find(i)
    d[root]=d.get(root,0)+1

print(max(d.values()))


Measured memory_bytes: 115144
#include<cstdio>
#include<stdio.h>
#include<string>
#include<iostream> 
#include<map>
using namespace std;
#include<algorithm>

bool two(int *a,int left,int right,int num){
	while(left<right){
		int mid=(left+right)/2;
		if(a[mid]==num){
			return true;
		}
		else if(a[mid]>num){
			right=mid;
		} 
		else if(a[mid]<num){
			left=mid+1;
		}
	}
	return false;
}

int main(){
	int n,q,a[100005],b[100005],count=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>b[i];
	}
	sort(a,a+n);
	for(int i=0;i<q;i++){
		if(two(a,0,n,b[i])){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3168
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef long long ijt;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

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

int main(void) {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	bool p = false, m = false;
	for (int i = 0; i < n; i++)
	{
		if (a[i] > 0)p = true;
		if (a[i] < 0)m = true;
	}
	bool right;
	if (p and !m) {
		right = true;
	}
	else if(!p and m) {
		right = false;
	}
	if (!p and !m) {
		cout << 0 << endl; return 0;
	}
	int absmax = a[0];
	int absmax_num = 0;
	vector<pair<int, int>> ans;
	if (p and m) {
		for (int i = 0; i < n; i++)
		{
			if (abs(a[i]) > abs(absmax)) {
				absmax = a[i];
				absmax_num = i;
			}
		}

		if (absmax > 0) {
			for (int i = 0; i < n; i++)
			{
			
				if (a[i] < 0) {
					ans.pb(mp(absmax_num + 1, i + 1));
					a[i] += absmax;
				}
			}
			right = true;
		}
		else {
			for (int i = 0; i < n; i++)
			{

				if (a[i] > 0) {
					
					ans.pb(mp(absmax_num + 1, i + 1));
					a[i] += absmax;
				}
			}
			right = false;
		}

	}

	if (right) {
		for (int i = 0; i < n-1; i++)
		{
			if (a[i] > a[i + 1]) {
				ans.pb(mp(i + 1, i + 2));
				a[i + 1] += a[i];
			}
		}
	}
	else {
		for (int i = n - 1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				ans.pb(mp(i + 1, i));
				a[i - 1] += a[i];
			}
		}
	}
	cout << ans.size() << endl;
	for (auto i : ans)cout << i.ff << " " << i.ss << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
signed main(){
	int n,m;
	string s,t;
	cin>>n>>m>>s>>t;
	for(int i=0;i<n;i+=n/gcd(n,m)){
		if(s[i]!=t[i*m/n]){
			puts("-1");
			return 0;
		}
	}
	cout<<n*m/gcd(n,m)<<endl;
	return 0;
}


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

int main() {
  string ABC = "abcdefghijklmnopqrstuvwxyz";
  char C;
  cin >> C;
  
  for (int i = 0; i < ABC.size(); i++) {
    if (C == ABC.at(i)) {
      cout << ABC.at(i+1) << endl;
      break;
    }
  }
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
vi g[125252];

int color[125252];
int ac,bc;
bool oddlen;

void dfs(int p,int c){
  color[p] = c;
  if(c==0)ac++;
  else bc++;
  for(int to : g[p]){
    if(color[to]==c){
      oddlen = true;
    }else if(color[to]==-1){
      dfs(to,1-c);
    }
  }
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  // odd len circle check
  ac=0;bc=0;
  oddlen = false;
  REP(i,n)color[i] = -1;
  dfs(0,0);
  ll ans = 0;
  if(oddlen){
    ans = (ll)n * (n-1) / 2;
  }else{
    ans = (ll)ac * bc;
  }
  ans -= m;
  printf("%lld\n",ans);
  return 0;
}


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

A.sort()

CB = [list(map(int, input().split()))[::-1] for _ in range(M)]
CB.sort()
C, B = list(map(list, zip(*CB)))
ans = []
b = B.pop()
c = C.pop()
for a in A:
    if a < c:
        ans.append(c)
        b -= 1
    else:
        ans.append(a)
    if not b:
        if B:
            b = B.pop()
            c = C.pop()
        else:
            c = -1

print(sum(ans))

Measured memory_bytes: 88428
// https://atcoder.jp/contests/abc116/tasks/abc116_b

#include <bits/stdc++.h>
using namespace std;

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

    vector<bool> used(1000001, false);
    used[s] = true;
    for (long i = 2; i <= 1000000; i++)
    {
        if (s & 1)
        {
            s = s * 3 + 1;
        }
        else
        {
            s /= 2;
        }
        if (used[s])
        {
            cout << i << endl;
            return 0;
        }
        used[s] = true;
    }
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  i64 p = (a1 - b1) * t1, q = (a2 - b2) * t2;
  if (0 < p)
  {
    p *= -1;
    q *= -1;
  }
  if (p + q < 0)
    cout << 0 << endl;
  else if (p + q == 0)
    cout << "infinity" << endl;
  else if (-p % (p + q) == 0)
    cout << -p / (p + q) * 2 << endl;
  else
    cout << -p / (p + q) * 2 + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    while(n > 10) {
        n %= 10;
    }
 
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << "\n";
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << "\n";
    } else {
        cout << "bon" << "\n";
    }
}




Measured memory_bytes: 3600
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&bs[i])
	}

	count := 0
	var x int
	for i := 0; i < n; i++ {
		sum := c
		for j := 0; j < m; j++ {
			fmt.Scan(&x)
			sum += x * bs[j]
		}
		if sum > 0 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	b string
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	b = scanner.Text()
	buff := bytes.NewBufferString("")
	max := 0

	for i := 0; i < len(b); i++ {
		if b[i] == 'A' || b[i] == 'C' || b[i] == 'G' || b[i] == 'T' {
			buff.WriteByte(b[i])
		} else {
			if max < buff.Len() {
				max = buff.Len()
				buff = bytes.NewBufferString("")
			}
		}
	}
	if max < buff.Len() {
		max = buff.Len()
	}

	fmt.Println(max)
}


Measured memory_bytes: 640
#include <iostream>

// int inf = 1 << 28;
int inf = 1000000000;

int dijk(int n,int s, int **g) {
	int sum = 0;
	bool *used = new bool[n];
	int *d = new int[n];

	// std::cout << "n = " << n << " " << "s = " << s << std::endl;

	for(int j=0;j<n;j++){
		for(int i=0;i<n;i++){
			std::cout << g[j][i] << ",";
		}
		std::cout << std::endl;
	}

	for(int i = 0; i < n; i++)
		d[i] = inf;
	d[s] = 0;

	while(true) {
		int u = -1;
		for(int v = 0; v < n; v++)
			if(!used[v] && (u == -1 || d[v] < d[u]))
				u = v;

		// std::cout << "u = " << u << std::endl;

		if(u == -1) break;
		used[u] = true;

		for(int v = 0; v < n; v++)
			if(d[v] > d[u] + g[u][v])
				d[v] = d[u] + g[u][v];
	}

	for(int i = 0; i < n; i++) {
		sum += d[i];
	}

	// for(int i = 0; i < n; i++) {
	// std::cout << d[i] << std::endl;
	// }

	return sum;
}

int main() {
	do {
		int **g; // adjacency matrix, ?
		int *d;
		int *a, *b, *c;
		int edge = 0, min = 0, max = 0;
		int tmp = 0;

		std::cin >> edge;
		if(!edge) break;

		a = new int[edge];
		b = new int[edge];
		c = new int[edge];

		for(int i = 0;i < edge;i++) {
			std::cin >> a[i];
			std::cin >> b[i];
			std::cin >> c[i];
		}

		for(int i = 0; i < edge; i++) {
			if(max < a[i])
				max = a[i];
		}
		for(int i = 0; i < edge; i++) {
			if(max < b[i])
				max = b[i];
		}
		max++;

		g = new int*[max];
		d = new int[max];

		for(int i = 0; i < max; i++) {
			g[i] = new int[max];
		}

		for(int i = 0; i < max; i++)
			for(int j = 0; j < max; j++)
				g[i][j] = inf;

		for(int i = 0; i < edge; i++)
			g[b[i]][a[i]] = g[a[i]][b[i]] = c[i];

		for(int i=0;i<max;i++){
			g[i][i]=0;
		}

		
		for(int k=0;k<max;k++){
			for(int j=0;j<max;j++){
				for(int i=0;i<max;i++){
					if(g[i][k]+g[k][j]<g[i][j]){
						g[i][j]=g[i][k]+g[k][j];
					}
				}
			}
		}
		

		for(int i = 0; i < max; i++)
			;//d[i] = dijk(max, i, g);

		for(int i = 0; i < max; i++){
			d[i]=0;
			for(int j=0;j<max;j++){
				d[i] += g[i][j];
			}
		}

		min = d[0];
		for(int i = 1; i < max; i++) {
			if(min > d[i]) {
				min = d[i];
				tmp = i;
			}
		}

		std::cout << tmp << " " << min << std::endl;
		for(int i = 0; i < max; i++)
			delete[] g[i];
		delete[] g;
		delete[] a;
		delete[] b;
		delete[] c;
		delete[] d;

	}while(true);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	long long int n,m;
	int i,j,k;
	cin>>n;
	m=n/11;
	m*=2;
	n%=11;
	if(n>6)m+=2;
	else if(n!=0)m++;
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
// Try NIKKEI Programming Contest 2019
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(usize));
    }
    
    let n = get!();
    let m = get!();
    let mut tree = vec![vec![]; n];
    let mut undi = vec![vec![]; n];
    let mut cnt = vec![0_i32; n];
    let mut pair = vec![std::usize::MAX; n];
    for _ in 0..n+m-1 {
        let a = get!() - 1;
        let b = get!() - 1;
        cnt[a] += 1;
        tree[a].push(b);
        undi[b].push(a);
    }
    
    let mut ps = vec![];
    
    for i in 0..n {
        if cnt[i] == 0 {
            ps.push(i);
        }
    }
    
    while !ps.is_empty() {
        for &p in ps.iter() {
            for &t in tree[p].iter() {
                if cnt[t] == 0 {
                    cnt[t] = -1;
                    pair[t] = p;
               }
            }
        }
        let mut es = vec![];
        for &p in ps.iter() {
            for &u in undi[p].iter() {
                cnt[u] -= 1;
                if cnt[u] == 0 {
                    es.push(u);
                }
            }
        }
        ps = es;
    }
    for &p in pair.iter() {
        if p == std::usize::MAX {
            println!("0");
        } else {
            println!("{}", p + 1);
        }
    }
}

Measured memory_bytes: 21244
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
lli a[200020];
lli b[200020];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli n = 0ll, k = 0ll, x = 0ll, pos = 0ll, neg = 0ll, l = LLONG_MIN / 2, h = LLONG_MAX / 2, c = 0ll, m = 0ll, res = 0ll, p = 0ll;
	cin >> n >> k;
	for (lli i = 0ll; i < n; ++i)
	{
		cin >> x;
		if (x >= 0ll)
		{
			a[pos] = x; ++pos;
		}
		else
		{
			b[neg] = x; ++neg;
		}
	}
	sort(a, a + pos);
	sort(b, b + neg, greater<lli>());
	while (l <= h)
	{
		c = 0ll;
		m = (l + h) / 2ll;
		if (m >= 0ll)
		{
			p = pos - 1ll;
			for (lli i = 0ll; i < pos; ++i)
			{
				while (p >= 0ll && a[p] * a[i] > m)
					--p;
				c += max(0ll, p - i);
			}
			p = neg - 1ll;
			for (lli i = 0ll; i < neg; ++i)
			{
				while (p >= 0ll && b[p] * b[i] > m)
					--p;
				c += max(0ll, p - i);
			}
		}
		p = 0ll;
		for (lli i = neg - 1ll; i >= 0ll; --i)
		{
			while (p<pos && a[p] * b[i]>m)
				++p;
			c += (pos - p);
		}
		if (c >= k)
		{
			res = m;
			h = m - 1ll;
		}
		else
			l = m + 1ll;
	}
	cout << res;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
 int n;
  cin >> n;
  long a[3*n];
  for(int i=0;i<3*n;i++) cin >> a[i];
  
  sort(a,a+3*n);
  
  long res=0;
  for(int i=n;i<3*n;i+=2) res+=a[i];

  cout << res << endl;
}

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

int main(){
  int N, K;
  cin >> N  >> K;
  int ans = 1;
  ans = ans * K;
  for(int i=0; i<N-1; i++){
    ans = ans * (K - 1);
  } 
  cout << ans << endl;
}



Measured memory_bytes: 256
def main():
    n, m = [int(i) for i in input().split()]
    ans = [0 for i in range(m+1)]
    for i in range(n):
        k, *a = [int(i) for i in input().split()]
        for j in range(k):
            ans[a[j]] += 1
    print(ans.count(n))
main()

Measured memory_bytes: 3060
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(n):
    if i != n-1 and p[i] == i+1:
        p[i+1], p[i] = p[i], p[i+1]
        count += 1
    elif i == n-1 and p[i] == i+1:
        p[i-1], p[i] = p[i], p[i-1]
        count += 1
print(count)


Measured memory_bytes: 14008
#include<iostream>
using namespace std;
int main() {
    char aa, bb, cc, dd; cin >> aa >> bb >> cc >> dd;
    int a = aa - '0';
    int b = bb - '0';
    int c = cc - '0';
    int d = dd - '0';
    if (a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d;
    else if (a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d;
    else if (a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d;
    else if (a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d;
    else if (a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d;
    else if (a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d;
    else if (a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d;
    else if (a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d;
    cout << "=7" << endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let v: Vec<u32> = read_vec();

    let  gcd_l: Vec<u32> = {
        let mut tmp = Vec::<u32>::new();

        tmp.push(0);
        
        for i in 0..n {
            let t = gcd(*tmp.last().unwrap(), v[i]);
            tmp.push(t);
        }

        tmp
    };

    let gcd_r: Vec<u32> = {
        let mut tmp = Vec::<u32>::new();
        tmp.push(0);

        for i in (0..n).rev() {
            let t = gcd(*tmp.last().unwrap(), v[i]);
            tmp.push(t);
        }

        tmp.reverse();
        tmp
    };

    let m: Vec<u32> = {
        let mut tmp = Vec::<u32>::new();
        for i in 0..n {
            tmp.push(
                gcd(gcd_l[i], gcd_r[i + 1])
            );
        }
        tmp
    };

    println!("{}", m.iter().max().unwrap());

}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_mat<T: std::str::FromStr>(row: u32) -> Vec<Vec<T>> {
    let mut vec = Vec::new();

    for _i in 0..row {
        vec.push(read_vec::<T>());
    }

    vec
}

fn gcd(a: u32, b: u32) -> u32 {
    if a == 0 { b }
    else { gcd(b % a, a) }
}

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

int main()
{
    // 整数の入力
    int a=0;
    string str,ans;

    cin >> a;
    cin >> str;
    
    if ( a < 3200)
    {
        ans = "red";
    }
    else 
    {
        ans =  str;
    }

    // 出力
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
keihin = [input().rstrip() for _ in range(N)]

counter = Counter(keihin)
print(len(counter))


Measured memory_bytes: 38820
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
constexpr auto mod = 1000000007;

using namespace std;
 


int main() {
int h,n;
  cin>>h>>n;
  int a;
  int sum=0;
  rep(i,n){
    cin>>a;
    sum+=a;
  }
  
  if(sum>=h){
    cout<<"Yes";}
  else{
    cout<<"No";
  }
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

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

int main() {
    ll a[MAXN];
    int n;
    int count_nega=0;
    bool zero = false;

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if ( a[i] < 0) {
            count_nega ++;
            a[i] = abs(a[i]);
        } else if (a[i] == 0) {
            zero = true;
        }
    }

    
    if ( count_nega %2 == 0 || zero ) {
    } else {

        sort(a, a+n);
        a[0] = -1 * a[0];
        
    }

    ll ans = 0;
    for(int i=0; i<n; i++) {
        ans += a[i];
    }
        
    cout << ans << endl;
}



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

ll solve() {
    ll N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            cin >> A[i][j];
        }
    }
    vector<ll> g(1<<N);
    for ( int b = 0; b < 1<<N; b++ ) {
        for ( int i = 0; i < N; i++ ) {
            for ( int j = i+1; j < N; j++ ) {
                if ( ((b >> i) & 1) && ((b >> j) & 1) ) g[b] += A[i][j];
            }
        }
    }
    vector<ll> dp(1<<N);
    for ( int b = 1; b < 1<<N; b++ ) {
        for ( int ms = b; ms > 0; ms--, ms &= b ) {
            dp[b] = max(dp[b], dp[b-ms] + g[ms]);
        }
    }
    return dp[(1<<N)-1];
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1280