akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int mod=1000000007;
int N,K,f[2010][2010];
ll fac[4000010],ifac[4000010];
ll inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
ll C(int n,int m){return n>=0&&m<=n?fac[n]*ifac[m]%mod*ifac[n-m]%mod:0;}
int main(){
	scanf("%d%d",&N,&K);
	if(K==1)puts("1");
	else{
		for(int i=*fac=1;i<=N*K;i++)fac[i]=fac[i-1]*i%mod;
		ifac[N*K]=inv(fac[N*K]);
		for(int i=N*K;i;i--)ifac[i-1]=ifac[i]*i%mod;
		f[1][0]=f[1][1]=1;
		for(int i=2;i<=N;i++){
			for(int j=N;j;j--)
				f[i][j]=(f[i][j+1]+f[i-1][j-1]*C(i*K-j-1,K-2))%mod;
			f[i][0]=f[i][1];
		}
		int ans=f[N][0]*fac[N]%mod;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>

using namespace std;

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

int main(){
    set<string> s;
    int n;
    cin >> n;
    rep(i, n){
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 19124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s;
    int n;
    cin >> n;
    int ans = 0;
    loop(i,1,n/2+1){
        int j = n-i;
        if(i != j)ans++;
    }
    cout << ans << endl;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a.at(i);
  ll j = 1, count = 0;
  rep(i, n) {
    if (a.at(i) == j) {
      count++;
      j++;
    }
  }
  if (count != 0)
    cout << n - j + 1 << endl;
  else
    cout << -1 << endl;
}

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

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    char data[100001];
    scanf("%s", data);
    int nai = 0, gai = 0;
    for (int i = 0; i < n; i++) {
        if (data[i] == 'a' ) {
            if (nai + gai < a+b) {
                nai++;
                puts("Yes");
            } else {
                puts("No");
            }
        } else if (data[i] == 'b' ) {
            if (nai + gai < a+b && gai < b) {
                gai++;
                puts("Yes");
            } else {
                puts("No");
            }
        } else {
            puts("No");
        }
    }
    









    return 0;
}



Measured memory_bytes: 768
H, W = map(int, input().split())
f = [list(input()) for _ in range(H)]
Y, X = [False for _ in range(H)], [False for _ in range(W)]
for y in range(H):
    for x in range(W):
        Y[y] |= f[y][x] == '#'
        X[x] |= f[y][x] == '#'
for y in range(H):
    flag = False
    for x in range(W):
        if Y[y] and X[x]:
            print(f[y][x], end = "")
            flag = True
    if flag:
        print()

Measured memory_bytes: 4596
n=int(input())
score=[[]for i in range(n)]
for i in range(n):
    x,y,z=map(int,input().split())
    score[i]=(x,y,z)
dp=[[0]*3 for i in range(n+1)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j!=k:
                dp[i+1][j]=max(dp[i+1][j],dp[i][k]+score[i][j])
print(max(dp[-1]))


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

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> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // 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 itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
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; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    int ans = 1e9;
    for(int A = 1; A < N; A++){
        int B = N - A;
        int this_ans = 0;
        for(int i = 0; i < to_string(A).size(); i++){
            this_ans += to_string(A)[i] - '0';
        }
        for(int i = 0; i < to_string(B).size(); i++){
            this_ans += to_string(B)[i] - '0';
        }
        ans = min(ans, this_ans);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import math
A,B = map(int,input().split())
x = math.ceil(A*12.5)
ans = -1
while(x < B*10+10):
    if((math.floor(x*0.08) == A) & (math.floor(x*0.1)==B)):
        ans = x
        break
    x+=1
print(ans)
    

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var A = Slist();
            var no = new long[N];
            for (var i = 0; i < N; ++i)
                no[A[i] - 1] = i + 1;
            WriteLine(String.Join(" ", no));
        }
    }
}

Measured memory_bytes: 30684
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll ans=0,mini,maxi,mod=1000000007,n,k;
    cin>>n>>k;
    for (ll i=k;i<=n+1;++i)
    {
        mini=i*(i+1);
        mini/=2;
        maxi=((n+1)*(n+2))/2;
        maxi-=((n+1-i)*(n+2-i))/2;
        ans+=maxi-mini+1;
        ans%=mod;
        //cout<<"i: "<<i<<" - maxi: "<<maxi<<" - mini: "<<mini<<"\n";
    }
    cout<<ans;
    return 0;
}

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

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

    cout<<fixed<<setprecision(10)<<(L*L*L/27)<<"\n";
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  map<long, long> M;
  for (long i = 1; i <= N; i++) {
    M[i] = 0;
  }
  long n;
  for (int x = 1; x <= 40; x++) {
    for (int y = x; y <= 58; y++) {
      for (int z = y; z <= 100; z++) {
        n = x*x + y*y + z*z + x*y + y*z + z*x;
        if (n > N) {
          break;
        }
        if ((x == y) && (y == z)) {
          M[n] += 1;
        } else if (((x == y) && (y != z)) || ((x != y) && (y == z)) ) {
          M[n] += 3;
        } else {
          M[n] += 6;
        }
      }
    }
  }
  for (const auto& [key, value] : M){
    cout << value << endl;
  }
}


Measured memory_bytes: 4120
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string s; cin >> s;
	int N = s.size();
	vector<vector<bool> > a(N + 1, vector<bool>(N + 1));
	for (int i = 0; i <= N; i++)
		a[i][i] = true;
	for (int d = 3; d <= N; d++)
		for (int l = 0; l + d <= N; l++) {
			int r = l + d;
			if (s[l] == 'm' && s[r - 1] == 'w');
			else continue;
			for (int i = l + 1; i + 1 <= r + 1; i++)
				if (s[i] == 'e' && a[l + 1][i] && a[i + 1][r - 1])
					a[l][r] = true;
		}
	cout << (a[0][N] ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 3228
N_nin, K_ko = map(int, input().split())

sunuke = []

for i in range(K_ko):
    d = int(input())
    
    A = list(map(int, input().split()))
    
    for a in A:
        sunuke.append(a)


ans = N_nin - len(set(sunuke))

print(ans)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  ll x,k,d; cin>>x>>k>>d;
  if (abs(x)/d > k){
    cout << abs(x) - k*d << endl;
    return 0;
  }
  else{
    if ((k-(x/d))%2 == 0){
      cout << abs(x)%d << endl;
      return 0;
    }
    else{
      cout << d - (abs(x)%d) << endl;
      return 0;
    }
  }
}

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

int main(){

    int N, X;
    int x[100000];
    cin >> N >> X;
    for( int i = 0; i < N; i++ ) cin >> x[i];


    // Xとの距離が最小のx[i]を求める
    int min_dist = abs( X - x[0] );

    for( int i = 1; i < N; i++ )
        min_dist = min( min_dist, abs(X - x[i]) );

    // 任意のiで (x[i] - X) % D == 0 となるようなDが求めるべきD
    bool check = false;

    for( int D = min_dist; D >= 1; D-- ){
        for( int i = 0; i < N; i++ ){
            if( ( x[i] - X ) % D != 0 ) break;
            if( i == N-1 ){
                check = true;
                break;
            }
        }
        if( check ){
            cout << D << endl;
            break;
        }
    }

    return 0;

}

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

int main()
{
  string s, t;
  cin >> s >> t;
  const int n = s.size();
  vector<vector<int>> next(n, vector<int>(26));
  for (char c = 'a'; c <= 'z'; c++) {
    int prev = -1;
    for (int i = 0; i < n; i++) {
      if (s.at(i) != c) continue;
      for (int j = prev + 1; j <= i; j++) next.at(j).at(c - 'a') = i - j + 1;
      prev = i;
    }
    if (prev != -1) {
      for (int i = prev + 1; i < n; i++) {
        next.at(i).at(c - 'a') = next.at(0).at(c - 'a') + n - i;
      }
    }
  }
  long total = 0;
  for (auto c : t) {
    int d = next.at(total % n).at(c - 'a');
    if (d == 0) {
      cout << -1 << endl;
      return 0;
    }
    total += d;
  }
  cout << total << endl;
}


Measured memory_bytes: 13824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
#include <queue>
using namespace std;


int main(){
  int N,M;
  cin>>N>>M;
  int a,b;
  vector<vector<int>> gh;
  gh.resize(N+100);
  //入次数の管理
  int h[N]={};
  int anc[N]={};
  //トポロジカルソート の実装
  for(int i=0;i<N+M-1;i++){
    cin>>a>>b;
    //aからbへの有向グラフ
    gh[a-1].push_back(b-1);
    h[b-1]+=1;
  }

  //入次数0の要素をキューとして管理
  queue<int> q;
  for(int i=0;i<N;i++){
    if(h[i]==0){
      q.push(i);
    }
  }

  vector<int> ans;
  int tmp,tmp_2;
  while(q.size()){
    int i=q.front();
    q.pop();
    ans.push_back(i);
    //隣接する頂点の入次数を-1する
      for(int j=0;j<gh[i].size();j++){
      tmp=gh[i][j];
      h[tmp]-=1;
      if(h[tmp]==0){
        q.push(tmp);
        anc[tmp]=i+1;
      }
    }

  }



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

return 0;
}

Measured memory_bytes: 7544
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;


int main (int argc, char const *argv[])
{
    string S;
    cin>>S;
    int ans=0;
    
    for(int i = 0; i < 4; i++)
    {
        
        if (S[i]=='+') {
            ans++;
        }
        else
        {
            ans--;
        }
        
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
for _ in [0]*int(input()):
    a,b,c,d,e,f,g,h=map(int,input().split())
    print(1 if (c-a)*(g-e)==-(d-b)*(h-f) else(2 if (c-a)*(h-f)==(d-b)*(g-e) else 0))

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

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

int main() {
	int x, n;
	int i, j;
	int buf;
	cin >> x >> n;
	int a[201] = { 0 };
	int ans;
	rep(i, n) {
		cin >> buf;
		a[buf]++;
	}
	for (i = 0; i <= 100; i++) {
		if (x - i >= 0) {
			if (a[x - i] == 0) {
				ans = x - i;
				break;
			}
		}
		else {
			ans = x - i;
			break;
		}
			
			if (a[x + i] == 0) {
				ans = x + i;
				break;
			}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3488
n = int(input())
my_dict = {}
for i in range(n):
    sorted_str = ''.join(sorted(list(input())))
    if not sorted_str in my_dict:
        my_dict[sorted_str] = 1
    else:
        my_dict[sorted_str] += 1
        
        
        
ret = 0
my_list = [i for i in my_dict.values() if i>1]
for j in my_list:
    ret +=  (j * (j-1) // 2)
    
    
print(ret)

Measured memory_bytes: 60632
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] res = helper(s);
        String ans = Integer.toString(res[0])+" "+Integer.toString(res[1]);
        System.out.print(ans);
    }
    static int[] helper(String s){
        int len = s.length();
        for(int i=0;i<26;i++){
            char cur = (char)(i+'a');
            int left=0;
            while(left<len-1){
                if(s.charAt(left)!=cur){
                    left++;
                    continue;
                }
                int right=left+1;
                if(s.charAt(right)==cur) return new int[]{left+1,right+1};
                right++;
                if(right<len&&s.charAt(right)==cur) return new int[]{left+1,right+1};
                left=right;
            }
        }
        return new int[]{-1,-1};
    }
}


Measured memory_bytes: 26268
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        int i, a[3];
     
        for(i=0; i<3; i++)
            cin>>a[i];
     
        sort(a, a+3);
     
        cout<<a[0]+a[1]+a[2]*10;
     
    }

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val readInts = { readLine()!!.split(" ").map { it.toInt() } }

    val (n, m) = readInts()

    val a = readInts().toIntArray().sortedArray().reversedArray()

    val bc = (1..m).map {
        val (b, c) = readInts()
        b to c
    }.sortedByDescending { it.second }

    var sum = 0L
    var count = n
    var ap = 0
    var bcp = 0
    while (count > 0) {

        if (bcp != bc.size && a[ap] <= bc[bcp].second) {
            val (b, c) = bc[bcp]
            val num = Math.min(count, b)
            sum += num.toLong() * c
            bcp++
            count -= num
        } else {
            sum += a[ap]
            ap++
            count--
        }
    }

    println(sum)
}


Measured memory_bytes: 95912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        long[] ABC = cin.ArrayLong(3,0);
        long ans=0;
        if(ABC[0]+ABC[1]>=ABC[2]-1)ans=ABC[2]+ABC[1];
        else ans=ABC[1]+Math.Min(ABC[0]+ABC[1]+1,ABC[2]);
        
        Console.WriteLine(ans);
        
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11220
Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
    if nxt=="a":
        if len(Sa)==0:
            winner = "A"
            break
        nxt = Sa[0]
        Sa=Sa[1:]
    elif nxt=="b":
        if len(Sb)==0:
            winner = "B"
            break
        nxt = Sb[0]
        Sb=Sb[1:]
    elif nxt=="c":
        if len(Sc)==0:
            winner = "C"
            break
        nxt = Sc[0]
        Sc=Sc[1:]

print(winner)

Measured memory_bytes: 3064
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            long X = int.Parse(ReadLine());
            long a;
            long b;

            a = X / 500;
            b = (X - a * 500) / 5;

            Write(1000 * a + 5 * b);
        }
    }
}

Measured memory_bytes: 11092
import math
from functools import reduce
n = int(input())
ans = 0
li = []
buf = n

def gcd(*numbers):
    return reduce(math.gcd,numbers)

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans += gcd(i,j,k)

print(ans)


Measured memory_bytes: 69776
#define _CRT_SECURE_NO_WARINGS
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <fstream>
#include <map>
#include <unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define endl '\n'
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i *PI / 180.0);
ll gcd(ll x, ll y)
{
    return (y == 0) ? x : gcd(y, x % y);
}
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int dy8[] = {0, 0, 1, -1, 1, -1, -1, 1};
int dx8[] = {1, -1, 0, 0, 1, -1, 1, -1};
int id8[] = {0, 1, 2, 3, 4, 5, 6, 7};
// Do Your Best

// First Contest Frome Ubuntu
int main()
{
    andrew;
    string a,b;
    cin>>a>>b;
    string ans="Yes";
    int u=0;
    for(int i=0;i<sz(a);i++)
    {
        if(a[i]!=b[i])
        {
            ans="No";
            break;
        }
    }
    cout<<ans<<endl;
   
}

Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner str = new Scanner(System.in);
        int N = str.nextInt();
        int NList[] = new int[N];

        for(int i = 0; i < N; i++){
            NList[i] = str.nextInt();
        }

        Arrays.sort(NList);

        for(int i = 0; i < N - 1; i++){
            if(NList[i] == NList[i + 1]){
                System.out.println("NO");
                return;
            }
        }

        System.out.println("YES");
        return;
    }
}

Measured memory_bytes: 84128
/*
       .-.,     ,.-.
 '-.  /:::\\   //:::\  .-'
 '-.\|':':' `"` ':':'|/.-'
 `-./`. .-=-. .-=-. .`\.-`
   /=- /     |     \ -=\
  ;   |      |      |   ;
  |=-.|______|______|.-=|
  |==  \  0 /_\ 0  /  ==|
  |=   /'---( )---'\   =|
   \   \:   .'.   :/   /
    `\= '--`   `--' =/'
      `-=._     _.=-'
           `"""`
*/

#include<bits/stdc++.h>

#define ll   	long long
#define pb	    push_back
#define F   	first
#define S	    second
#define B   	begin()
#define E	    end()
#define FASTIO   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


using namespace std ;

int main()
{
    FASTIO
    ll a ;
    cin >> a ;
    cout << a + a*a + a*a*a ;
    return 0 ;
}


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

int main() {  
  vector<vector<int>> c(3, vector<int>(3));
  for(int i = 0; i < 3; i++) {
  	for(int j = 0; j < 3; j++) {
    	cin >> c.at(i).at(j);
    }
  }
  vector<int> a(3);
  vector<int> b(3);
  a[0] = 0;
  for(int i = 0; i < 3; i++){
  	b.at(i) = c.at(0).at(i);
  }
  for(int i = 1; i < 3; i++) {
  	a.at(i) = c.at(i).at(0) - b.at(0);
  }
  bool ans = true;
  for(int i = 0; i < 3; i++) {
  	for (int j = 0; j < 3; j++) {
    	if(c.at(i).at(j) != a.at(i) + b.at(j)) {
        	ans = false;
          break;
        }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cnt = 0, xa, xb, xc;
    for (int i = 0; i <= A; i++) {
        xa = 500 * i;
        if (xa > X) break;
        for (int j = 0; j <= B; j++) {
            xb = xa + 100 * j;
            if (xb > X) break;
            for (int k = 0; k <= C; k++) {
                xc = xb + 50 * k;
                if (xc == X) {
                    cnt++;
                    break;
                }
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3592
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,n = list(map(int, input().split()))
from collections import defaultdict, Counter
d = defaultdict(int)
for i in range(n):
    a,b = map(int, input().split())
    for i in range(a-2, a+1):
        for j in range(b-2, b+1):
            if 1<=i<=h-2 and 1<=j<=w-2:
                d[i,j] += 1
ans = [None]*10
ans[0] = (h-2)*(w-2) - len(d)
c = Counter(d.values())
for i in range(1,10):
    if i in c:
        ans[i] = c[i]
    else:
        ans[i] = 0
write("\n".join(map(str, ans)))
    

Measured memory_bytes: 232500
# encoding: utf-8

import sys
from collections import deque


class Solution:
    @staticmethod
    def doubly_linked_list():
        # write your code here
        array_length = int(input())
        task_deque = deque()
        _input = sys.stdin.readlines()

        for i in range(array_length):
            l_arg = _input[i].split()
            action = _input[i].split()[0]
            if len(l_arg) > 1:
                value = _input[i].split()[-1]
            # print(action, 'v', value)

            if action == 'insert':
                task_deque.appendleft(value)
            elif action == 'deleteFirst':
                task_deque.popleft()
            elif action == 'deleteLast':
                task_deque.pop()
            elif action == 'delete':
                try:
                    task_deque.remove(value)
                except Exception as e:
                    pass
        print(" ".join(task_deque))


if __name__ == '__main__':
    solution = Solution()
    solution.doubly_linked_list()

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

using iter = decltype(cbegin(string()))&;

int num(iter it) {
  assert(isdigit(*it));
  return *it++ - '0';
}
int term(iter it) {
  int res = num(it);
  while (*it == '*') {
    res *= num(++it);
  }
  return res;
}
int expr(iter it) {
  int res = term(it);
  while (*it == '+') {
    res += term(++it);
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n;
  cin >> n;
  auto it = cbegin(s);
  int a = expr(it);
  assert(*it == 0);
  int b = s[0] - '0';
  for (int i = 1; i < (int)s.size(); i += 2) {
    if (s[i] == '+') {
      b += s[i + 1] - '0';
    } else {
      b *= s[i + 1] - '0';
    }
  }
  if (n == a and n == b) {
    cout << "U\n";
  } else if (n == a) {
    cout << "M\n";
  } else if (n == b) {
    cout << "L\n";
  } else {
    cout << "I\n";
  }
}



Measured memory_bytes: 3228
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
a = input()

if len(str(a)) == 1:#1~9
    print("{}".format(a))
elif len(str(a)) == 2:  #10~99
    print("9")
elif len(str(a)) == 3: #100~999
    print("{}".format(int(str(a)) - 90))
elif len(str(a)) == 4:  #1000~9999
    print("909")
elif len(str(a)) == 5:  # 10000~99999
    print("{}".format(int(str(a)) - 9090))
else:
    print(90909)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 500005
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define PF push_front
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n)
 
#define ll 	  long long 
 
#define mod  1000000007



int main()
{
	FAST;
	int n, k;
	cin >> n >> k;
	int a[max(n, k) + 6] = {0};
	ll int x = 0;
	for(int i = 0; i < n; i ++){
		cin >> a[i];
		x += a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	for(int i = 0; i < k; i ++){
		x -= a[i];
	}
	if(k >= n){
		x = 0;
	}
	cout << x;
	return 0;
}

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

#define MAXN (100010)
#define ll long long

int n, root;
ll a[MAXN];
std::vector<std::pair<int, ll> > vec[MAXN];

bool dfs(int u, std::pair<int, ll>& fae, int fa){
	ll tmp = 0;
	if(vec[u].size() == 1){
		fae.second += a[u];
		return true;
	}
	for(auto &p : vec[u]){
		int v = p.first;
		if(v == fa) continue;
		if(!dfs(v, p, u) || p.second > a[u]){
			return false;
		}
		tmp += p.second;
	}
	if(2 * a[u] < tmp || u == root && 2 * a[u] != tmp || a[u] > tmp) return false;
	fae.second += 2 * a[u] - tmp;
	return true;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i) scanf("%lld", a + i);
	for(int i = 1; i < n; ++ i){
		int u, v;
		scanf("%d%d", &u, &v);
		vec[u].push_back({v, 0});
		vec[v].push_back({u, 0});
	}
	if(n == 2) return printf(a[1] == a[2] ? "YES\n" : "NO\n"), 0;
	for(int i = 1; i <= n; ++ i){
		if(vec[i].size() > 1){
			root = i;
			printf(dfs(i, *(new std::pair<int, ll>), 0) ? "YES\n" : "NO\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 14720
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))


def search(a, X):
  l = 0
  r = len(X) 
  while l < r:
    m = (l + r ) // 2
    if a == X[m]:
      return m
    elif a > X[m]:
      l = m + 1
    elif a < X[m]:
      r = m
  return None
    

s = 0
for t in T:
  if search(t,S) is not None:
    s += 1
print(s)






Measured memory_bytes: 16712
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int a,b,c;cin>>a>>b>>c;
	cout<<c/a*b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int tmp1,tmp2,tmp3,count=0;

    if(a%2!=0||b%2!=0||c%2!=0){
            cout << 0 << endl;
            return 0;
        }
    for(int i=0;i<100000;i++){
        tmp1 = b/2+c/2;
        tmp2 = a/2+c/2;
        tmp3 = a/2+b/2;
        a = tmp1; b = tmp2; c = tmp3;
        count++;
        if(a%2!=0||b%2!=0||c%2!=0){
            cout << count << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main(void){
    stack<int> s;
    string n;
    while(cin >> n){
        if(!(n[0] >= '0' && n[0] <= '9')){
            int a, b;
            b = s.top(); s.pop();
            a = s.top(); s.pop();
            if(n[0] == '+') s.push(a + b);
            if(n[0] == '-') s.push(a - b);
            if(n[0] == '*') s.push(a * b);
        }
        else {
            int x = 0, p = 1;
            for(int i = n.size() - 1; i >= 0; --i){
                x += (n[i] - '0') * p;
                p *= 10;
            }
            s.push(x);
        }
    }
    cout << s.top() << endl;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    string s[3];
    rep(i, 0, 3) cin >> s[i];
    int ans = -1, now = 0;
    rep(i, 0, 1000001){
        int tmp;
        tmp = s[now][0] - 'a';
        s[now] = s[now].substr(1);
        now = tmp;
        if(s[now].size() == 0){
            ans = now;
            break;
        }
    }
    cout << (char)('A' + ans) << endl;
}

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

int main(void)
{
	int n, k, q;
	int ans[100000];
	int a;

	scanf("%d %d %d", &n, &k, &q);

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

	if (k > q)
	{
		for (int i = 0; i < n; i++)
		{
			printf("Yes\n");
		}
		return 0;
	}

	for (int i = 0; i < q; i++)
	{
		scanf("%d",&a);

		ans[a - 1]++;
	}

	int r = 0;

	for (int i = 0; i < n; i++)
	{
		r = k - q + ans[i];
		if (r > 0)printf("Yes\n");
		else printf("No\n");
	}
	


	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  vin a(n);
    map<int,int> m;
  rep(i,0,n) {
    cin>>a[i];
    m[a[i]]++;
  }
  int ans=0;
  rep(i,1,1e5){
    int x=i;
    int cnt=0;
    cnt+=m[i];
    if(i-1>=0) cnt+=m[i-1];
     cnt+=m[i+1];
    chmax(ans,cnt);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,d,x;
  cin >> n>>d>>x;
  int ans =x;
  for(int i =0;i<n;i++){
    int a;
    cin >> a;
    for(int j = 0;(1+a*j)<=d;j++){
      ans++;
    }
  }
  cout <<ans;
      
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << (H - h)*(W - w)<<endl;
  	return 0;
}

Measured memory_bytes: 256
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

int main(){

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

	int dp[n];
	for(int i=n-2;i>=n-k-1;i--) dp[i]=abs(h[n-1]-h[i]);
	dp[n-1]=0;
	
	for(int i=n-k-2;i>=0;i--){
		dp[i]=INT_MAX;
		for(int j=i+1;j<=i+k;j++){
			dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
		}
	}

	cout<<dp[0]<<endl;

	return 0;
} 

Measured memory_bytes: 1024
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size()) 
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[1050];
int main() {
	scanf("%s", in);
	if (in[0] == 'Y' && in[1] == 'A' && in[2] == 'K' && in[3] == 'I') printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b;
    cin>>a>>b;
    if ((3!=a)and(3!=b))
        cout<<3;
    else if ((2!=a)and(2!=b))
        cout<<2;
    else if ((1!=a)and(1!=b))
        cout<<1;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main() {
	int n, m, s, g1, g2;

	while( true ){
		cin >> n >> m >> s >> g1 >> g2;

		if(n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0) {
			break;
		}

		int b1;
		int b2;
		int c;

		vector< vector < int > > map(n + 1, vector< int >(n + 1, INT_MAX / 4));

		for(int i = 0; i < m; i++) {
			cin >> b1 >> b2 >> c;
			map[b1][b2] = c;
		}
		for(int i = 0; i < n + 1; i++) {
			map[i][i] = 0;
		}
		
		for(int k = 0; k <= n; k++) {
			for(int i = 0; i <= n ; i++) {
				for(int j = 0; j <= n; j++) {
					map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
				}
			}
		}
		
		int total = INT_MAX / 2;
		for(int k = 0; k <= n; k++) {
			total = min(total, map[s][k] + map[k][g1] + map[k][g2]);
		}

		cout << total << endl;

	}
}

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

int main()
{
    long long int t;
    cin>>t;
    if(t>29)
    {
        cout<<"Yes\n";
    

        
    }
    else 
    {
        cout<<"No\n";
    
    }
    
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n string
	fmt.Scan(&n)
	nums := make([]int, len(n))
	for i := 0; i < len(n); i++ {
		nums[i], _ = strconv.Atoi(string(n[i]))
	}
	for bits := 0; bits < (1 << uint64(3)); bits++ {
		res := nums[0]
		resStr := strconv.Itoa(nums[0])
		resNums := nums[1:]
		for i := 0; i < 3; i++ {
			if bits>>uint64(i)&1 == 1 {
				res += resNums[i]
				resStr += "+"
				resStr += strconv.Itoa(resNums[i])
			} else {
				res -= resNums[i]
				resStr += "-"
				resStr += strconv.Itoa(resNums[i])
			}
		}
		if res == 7 {
			resStr += "=7"
			fmt.Println(resStr)
			return
		}
	}
}


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

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

    int ans = 700;
    if (s[0] == 'o') { ans += 100; }
    if (s[1] == 'o') { ans += 100; }
    if (s[2] == 'o') { ans += 100; }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long int N,A,B;
  long long int i;
  long long int h[100000];
  long long int K;
  long long int left,right;
  long long int sum;

  scanf("%lld %lld %lld",&N,&A,&B);
  //printf("%d\n", N);

  for(i=0;i<N;++i){
    scanf("%lld",&h[i]);
    //printf("h[%lld]=%lld\n", i,h[i]);
  }

  left=0;
  right=1000000000;
  K=(right+left)/2;

  //printf("%d\n", K);

  while(1){
    sum=0;
    for(i=0;i<N;i++){
      if(h[i]-K*B > 0){
        sum += (h[i]-K*B)%(A-B) ? (h[i]-B*K)/(A-B)+1 :(h[i]-B*K)/(A-B);
      }
    }
    if(sum <= K){
      right=(right+left)/(long long int)2;
    }else{
      left=(right+left)/(long long int)2;
    }
    //printf("%lld,%lld\n", left,right);
    K=(right+left)/2;
    if(left==right-1){
      break;
    }
  }

  printf("%lld\n", right);

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    ll ans = INF;
    for(int i = 1; i < n; i++)
    {
        ll x = __gcd(v[i], v[i - 1]);
        ans = min(x, ans);
    }
    cout << ans << endl;
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    string S[n];
    int P[n];
    vector<pair<pair<string, int>, int>> v;
    for (int i = 0; i < n; i++)
    {
        cin >> S[i] >> P[i];
        v.push_back(make_pair(make_pair(S[i], -P[i]), i + 1));
    }
    sort(v.begin(), v.end());
    for (auto p : v)
    {
        cout << p.second << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i, j, m, n, cnt1, cnt2=0, ans;

  scanf("%d%d", &m , &n);

  for(i = 0; i < m; i++){
    cnt1 = 0;
    
    for(j = 0; j < n; j++){
      scanf("%d", &ans);
      if(ans == 1) cnt1++;
      
    }
    if(cnt2 < cnt1) cnt2 = cnt1;
    
  }

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

  return 0; 

}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	string str, num;
	int ans = 0;
	while (cin >> str) {
		for (int i = 0; i < str.size(); i++) {
			num = "";
			for (int j = 0; isdigit(str[i]); i++, j++) {
				num += str[i];
			}
			if (num != "")
				ans += atoi(num.c_str());
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int A[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N)  cin >> A[i];
    int right = 0;
    ll ans = 0;
    int sumX = A[0];
    int sum = A[0];
    for(int left = 0; left < N; left++) {
        while(right + 1 < N && (sumX ^ A[right + 1]) == sum + A[right + 1]) {
            right++;
            sumX ^= A[right];
            sum += A[right];
            
        }
        //cout << left << " " << right << "xxx" << sumX << " " << sum << endl;
        ans += right - left + 1;
        if (left + 1 > right) {
            right++;
            sumX ^= A[right];
            sum += A[right];
        }
        sumX ^= A[left];
        sum -= A[left];
    }
    cout << ans << endl;


    return 0;
}


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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a * b,c * d) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<stack>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 510000
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;}
using namespace std;


int main(){
  ll H,W;
  cin>>H>>W;
  if(H==1 || W==1) cout<<1<<endl;
  else cout<<(H*W+1)/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

int main(){
	std::string S;
	std::cin >> S;


	auto count_ =	std::count( S.cbegin(), S.cend(), 'R' );

	auto ans =
		count_ != 2 ? count_ : S[1] != 'R' ? 1 : count_;


	std::cout << ans << "\n";

	return 0;
}

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

int main ()
{
    int N;
    int A[1010];
    cin >> N ;
    for(int k=0;k<N;k++){
        cin >> A[k];
    }
    int minj,v;
    int cnt=0;
    int j;
    for(int i=0;i<N;i++){
        minj=i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]) minj=j;
        }
        if(i!=minj){
            v=A[i];
            A[i]=A[minj];
            A[minj]=v;
            cnt++;
        }
    }
    for(int k=0;k<N;k++){
        if(k==N-1) cout << A[k] << endl;
        else if(k!=N-1) cout << A[k] << " ";
    }
    cout << cnt << endl;
}










Measured memory_bytes: 3092
from sys import stdin

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n,k,x,y=[I() for i in range(4)]

ans = 0
for i in range(n):
    if i<k:
        ans += x
    else:
        ans += y
print(ans)

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

using namespace std;

void swap(int* a, int* b){
	int temp = *b;
	*b = *a;
	*a = temp;
}
int main(){
	int n, x;
	cin >> n >> x;
	if(x == 1 || x == 2*n-1){
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	int arr[2*n];
	for(int i = 0; i < 2*n; i++){
		arr[i] = i;
	}
	// arr[n] = x;
	// arr[x] = n;
	swap(arr + n, arr + x);
	// arr[n-1] = 1;
	// arr[1] = n-1;
	swap(arr + 1, arr + n-1);
	// arr[n+1] = 2*n-1;
	// arr[2*n-1] = n+1;
	swap(arr + n+1, arr + 2*n - 1);
	for(int i = 1; i < 2 * n; i++){
		cout << arr[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
vector <ll> a(100002);
int main() {
    int N , T;
	cin >> N;
	cin >> T;
	for(int i = 1; i < N; i++) {
        int a;
        cin >> a;
		T = gcd(a , T);
	}
	cout << T << endl;;
}

Measured memory_bytes: 3800
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
# import numpy as np
 
DIV_NUM = 1000000000 + 7
 
INPUT_NUMS = list(map(int, input().split()))
N=int(INPUT_NUMS[0])
K=int(INPUT_NUMS[1])
 
A = [int(x) for x in input().split()]
#AA = np.array(A , dtype='int64')

if N==1:
    print(0)
    exit()


nn=int(math.log2(2000))+1
tree = [0] * (2**nn)

def BIT_update(tree,x):
    while x <= 2000:
        tree[x] += 1
        y = x
        z = 1
        while y > 0:
            if y % 2 == 1:
                x += z
                break
            y //= 2
            z *= 2

def BIT_sum(tree,x):
    s = 0
    while x > 0:
        s += tree[x]
        y = x
        z = 1
        while y > 0:
            if y % 2 == 1:
                x -= z
                break
            y //= 2
            z *= 2
    return s
 
answer = N*(N-1)//2
for i in A:
    answer -= BIT_sum(tree,i)
    BIT_update(tree,i)

B = sorted(A)
 
q=0
p=B[0]
r=0
for i in range(1,N):
    if B[i]>p:
        p=B[i]
        r=i
    q += r
 
answer = answer * K + q * K * (K-1) // 2
answer = answer % DIV_NUM
print(answer)
 

Measured memory_bytes: 3316