akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int N = 2e5 + 10;
ll c[N], sum[N], dp[N];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &c[i]);
	sum[1] = c[1];
	for (int i = 3; i <= n; i += 2)
		sum[i] = sum[i - 2] + c[i];
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		if (i & 1)
			dp[i] = max(dp[i - 1], dp[i - 2] + c[i]);
		else 
			dp[i] = max(dp[i - 2] + c[i], sum[i - 1]);
	}
	printf("%lld", dp[n]);
}
/*
27
18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49
*/

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

int main(){
    int i,a;
    a = 1;
    for(;;){
    cin >> i;
    if ( i == 0 ) break;
    cout << "Case" << " " << a << ": " << i << endl;
    a++;
    }
  return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
int32_t main()
{

     lli h1,m1,h2,m2,k,ans=0;
     cin>>h1>>m1>>h2>>m2>>k;
     lli h,m;
     if(h1==h2) { m=m2-m1; ans=m-k; }
     else
     {
         m=60-m1;

         h1++;

         h=h2-h1;

         m+=m2;

         ans=m+(60*h);
         ans-=k;
     }
     cout<<ans<<"\n";
   return 0;
}//main


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        for(int i = 0; i < n; i++){
            int pm,pe,pj;
            int heikin = 0;
            cin >> pm >> pe >> pj;
            heikin = pm + pe + pj;
            heikin /= 3;
            if(pm == 100 || pe == 100 || pj == 100) cout << "A" << endl;
            else if((pm + pe) / 2 >= 90) cout << "A" << endl;
            else if(heikin >= 80) cout << "A" << endl;
            else if(heikin >= 70) cout << "B" << endl;
            else if(heikin >= 50 && pm >= 80 || pe >= 80) cout << "B" << endl;
            else cout << "C" << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
//    int n ;
//    cin>>n;
//    long long ans[10000];
//    long long sum = 0;
//    for(int i = 0; i < n; i++)
//    {
//        cin>>ans[i];
//        sum+=ans[i];
//    }
//
//    long long u = sum/n;
//    cout<<u<<endl;
//    long long sums = 0;
//    for(int i = 0;i<n;i++)
//    {
//        sums=sums + (ans[i]-u)*(ans[i]-u);
//    }
//    cout<<sums<<endl;
    int a[4]; int num =0 ;
        int nums=  0;
    for(int i =0;i<3;i++)
    {
        cin>>a[i];

        if(a[i]==5)
            num++;
        if(a[i] == 7)
            nums++;
    }
    if(num==2&&nums==1)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

int main()
{	
	int t=1;
	//cin>>t;
	while(t--){
        int n,sum=0;
		cin>>n;
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				sum=sum+v[i]*v[j];
			}
		}
		cout<<sum<<endl;
	}
	//chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
	//chrono::high_resolution_clock::time_point t2 = chrono::high_resolution_clock::now();
	//chrono::duration<double> time_span = (t2 - t1);
	//cout<<time_span.count()<<" Seconds"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<pair<int,int>>A(M);
  for(int i=0;i<M;i++){
  int a,b;
    cin>>a>>b;
    pair<int,int>p(b,a);
    A.at(i)=p;
  }sort(A.begin(),A.end());
  int ans=0;
  int right=0;
  for(int i=0;i<M;i++){
   int a=A.at(i).second;
    int b=A.at(i).first;
    if(right<a){
      right=b-1;
      ans++;
    }
  }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
// C++test1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793



int main() {
    ll n,k;
    cin >> n;
    cin >> k;
    vector<ll> p(n);
    rep(cnt, 0, n) {
        cin >> p[cnt];
    }
    sort(p.begin(), p.end());
    ll ans = 0;
    rep(cnt, 0, k) {
        ans += p[cnt];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        while (true)
        {
            var wh = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var w = wh[0];
            var h = wh[1];
            if (w == 0) break;
            var map = Enumerable.Repeat(0, h).SelectMany(_ => Console.ReadLine()).ToArray();

            List<int>[] graph = Enumerable.Repeat(0, h * w).Select(_ => new List<int>()).ToArray();
            for (int i = 0; i < h - 1; i++)
                for (int j = 0; j < w; j++)
                { var id = i * w + j; graph[id].Add(id + w); graph[id + w].Add(id); }
            for (int i = 0; i < h; i++)
                for (int j = 0; j < w - 1; j++)
                { var id = i * w + j; graph[id].Add(id + 1); graph[id + 1].Add(id); }

            var sInd = Array.IndexOf(map, '@');


            int res = 0;
            var arrived = new bool[w * h];
            Stack<int> stack = new Stack<int>();
            stack.Push(sInd);
            arrived[sInd] = true;
            while (stack.Count != 0)
            {
                var elem = stack.Pop();
                res++;
                foreach (var item in graph[elem])
                {
                    if (map[item] == '#') continue;
                    if (arrived[item]) continue;
                    arrived[item] = true;
                    stack.Push(item);
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 18740
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int M = sc.nextInt();
   
   int min = 1;
   int max = N;
   
   for(int i=1;i<=M;i++)
   {
    int L = sc.nextInt();
    int R = sc.nextInt();
     
     if(min<L) min = L;
     if(max>R) max = R;
     
   }
   
  if(max>=min) System.out.println(max-min+1);   
  else System.out.println(0);   
 }
}

Measured memory_bytes: 62056
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using namespace atcoder;

const int MAX = 300000;

int op(int a, int b) {
  return max(a, b);
}

int e() {
  return 0;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  segtree<int, op, e> sg(MAX+1);
  rep(i, N) {
    sg.set(A[i], max(sg.get(A[i]), sg.prod(max(0, A[i]-K), min(MAX+1, A[i]+K+1)) + 1));
  }
  cout << sg.all_prod() << endl;
  return 0;
}


Measured memory_bytes: 9260
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.print(a*b);
        System.out.print(" ");
        System.out.println(2*(a+b));
    }
}


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  int Q; cin >> Q;
  int flag = true;
  string ansf, ansb, ansfr,ansbr;
  REP(i, Q){
    int T; cin >> T;
    if(T == 1){
      if(flag){
        flag = false;
      }else{
        flag = true;
      }
    }else{
      int F; cin >> F;
      string s; cin >> s;
      if(F == 1 && flag || F == 2 && flag == false){
        ansf.append(s); //
        ansbr.append(s);
      }else{
        ansb.append(s);
        ansfr.append(s); //
      }
    }
  }
  if(flag == false){
    reverse(ansfr.begin(), ansfr.end());
    cout << ansfr;
    for(int i = N-1; i >= 0; i--){
      cout << S[i];
    } 
    cout << ansbr << endl;
  }else{
    reverse(ansf.begin(), ansf.end());
    cout << ansf << S << ansb << endl;
  }
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  ll g = A[0];
  rep(i, n) g = gcd(g, A[i]);
  if(k <= *max_element(all(A)) && k % g == 0) cout << "POSSIBLE" << "\n";
  else cout << "IMPOSSIBLE" << "\n";
  return 0;
}


Measured memory_bytes: 3908
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int k;
     cin >> k;
     string a,b;
    cin >> a>>b;
    for(int i = 0;i<k;i++){
        cout<<a[i]<<b[i];  
    }
 
    return 0;
}

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

int main() {
  int n[4];
  cin >> n[0] >> n[1] >> n[2] >> n[3];
  sort(n, n + 4);
  if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) cout << "YES" << endl;
  else cout << "NO" << endl; 
  return 0;
}


Measured memory_bytes: 256
import itertools as it


N = int(input()) - 1
s = list(map(int, input().split()))
count = 0

c = it.combinations(s, 3)

for i in c:
    listed = list(i)
    if listed[0] == listed[1] or listed[1] == listed[2] or listed[2] == listed[0]:
        continue
    maximum = max(listed)
    listed.remove(maximum)
    if (listed[0] + listed[1]) > maximum:
        count += 1

print(count)

Measured memory_bytes: 9108
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
vector<int> graph[10000];
int c[10000];
int s[10000];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        scanf(" %d %d", &a, &b);
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for (int i = 0; i < N; ++i) { scanf(" %d", c+i); }
    sort(c, c+N, greater<int>());
    fill(s, s+N, -1);

    int tot_score = -c[0];
    for (int i = 0; i < N; ++i) tot_score += c[i];

    int start;
    for (int i = 0; i < N; ++i) {
        if (graph[i].size() == 1) {
            start = i;
            break;
        }
    }

    queue<int> q;
    q.push(start);
    int idx = 0;
    s[start] = c[idx++];
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (int y : graph[x]) {
            if (s[y] == -1) {
                s[y] = c[idx++];
                q.push(y);
            }
        }
    }

    cout << tot_score << endl;
    for (int i = 0; i < N; ++i) cout << s[i] << " ";
    cout << endl;

    return 0;
}


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

const int MAXN = 100000;
char res[MAXN + 10];

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int mask = 0; mask < (1 << 3); mask++) {
        for(int i = 0; i < n; i++)
            res[i] = 'S';
        for(int i = 0; i < 3; i++) {
            if(mask & (1 << i))
                res[i] = 'W';
        }
        for(int i = 2; i < n; i++) {
            if(res[i] == 'S') {
                if(s[i] == 'o')
                    res[i + 1] = res[i - 1];
                else
                    res[i + 1] = 'S' + 'W' - res[i - 1];
            }
            else {
                if(s[i] == 'x')
                    res[i + 1] = res[i - 1];
                else
                    res[i + 1] = 'S' + 'W' - res[i - 1];
            }
        }
        bool ok = true;
        for(int i = 0; i < n; i++) {
            if(res[i] == 'S') {
                if(s[i] == 'o') {
                    if(res[(i - 1 + n) % n] != res[(i + 1) % n])
                        ok = false;
                }
                else {
                    if(res[(i - 1 + n) % n] == res[(i + 1) % n])
                        ok = false;
                }
            }
            else {
                if(s[i] == 'o') {
                    if(res[(i - 1 + n) % n] == res[(i + 1) % n])
                        ok = false;
                }
                else {
                    if(res[(i - 1 + n) % n] != res[(i + 1) % n])
                        ok = false;
                }
            }
        }
        if(ok) {
            for(int i = 0; i < n; i++)
                cout << res[i];
            cout << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        private class Data
        {
            public long prime;
            public long cnt;
            public Data(long prime, long cnt)
            {
                this.prime = prime;
                this.cnt = cnt;
            }
        }
        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int w = o[0];
            int a = o[1];
            int b = o[2];

            int ans = 0;
            if( b > a+ w)
            {
                ans = b - (a + w);
            }else if( b+w < a)
            {
                ans = a - (b + w);
            }
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>																							   
																									   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1e9;
const long long INFL = 1e18;																					   
const int mod = 1e9 + 7;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii;																							   										   
typedef vector<ii> vii; 		   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq;    																								   																				   																						   
																													   																				   										   
#define pb push_back																							   
#define pf push_front																							   
#define mp(x, y) make_pair(x, y)
#define size(x) (int)x.size()
#define endl '\n'

int _X[] = {0, 1, 1, 1, 0, -1, -1, -1};
int _Y[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int _X2[] = {1, 0, -1, 0};
int _Y2[] = {0, 1, 0, -1};

int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	
    int n;
    cin >> n;
    vi tab(n);
    for(int i = 0; i < n; i++){
        cin >> tab[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(i != j && j != k && i != k){
                    if(tab[i] + tab[j] > tab[k] && tab[i] + tab[k] > tab[j] && tab[j] + tab[k] > tab[i] && tab[i] != tab[j] && tab[i] != tab[k] && tab[j] != tab[k]){
                        ans++;
                    }                   

                }
            }
        }
    }

    cout << ans << endl;





	
	
	
	
	return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}


void solve(){
  string s, t;
  cin >> s >> t;

  vector<int> num[30];

  rep(i, s.size()){
    num[s[i] - 'a'].push_back(i);
  }

  ll res = 0;
  int x = -1;
  rep(i, t.size()){
    auto iter = upper_bound(ALL(num[t[i]-'a']), x);

    if(iter != num[t[i] - 'a'].end()){
      x = *iter;
    }else{
      x = -1;
      res +=s.size();
      auto iter2 = upper_bound(ALL(num[t[i]-'a']), x);
      if(iter2 != num[t[i] - 'a'].end()){
        x = *iter2;
      }else{
        cout << -1 << endl;
        return;
      }
    }
  }

  res += x;
  cout << res + 1 << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}

signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	int h, n;
	cin >> h >> n;
	vector<P> ab(n);
	rep(i, n) {
		cin >> ab[i];
	}
	vector<vector<int>> dp(n, vector<int>(h+16384, INT_MAX));
	dp[0][0]=0;
	rep(i, n) {
		rep(j, h+16384) {
		    if(i){
		        dp[i][j]=min(dp[i-1][j],dp[i][j]);
		    }
		    if(j-ab[i].first>=0){
		        dp[i][j]=min(dp[i][j-ab[i].first]+ab[i].second,dp[i][j]);
		    }
		}
	}
	int ans=INT_MAX;
	rep(i,h,h+16384){
	    ans=min(ans,dp[n-1][i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 208512
#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 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 DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

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

int n,k;
int r,s,p;
string t;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>t;

    int ans = 0;
    //int pos=0;
    //"ちょうど"K回前のじゃんけんで出した手と同じ手を出すことはできない
    //グーで勝つ
    auto pos = t.find('s', 0);
    vector<bool> v(n,false);
    while (pos != string::npos) {
        if(pos<k || !(t[pos-k] == 's' && v[pos-k])){
            //DEBUG2("r", pos);
            ans += r;
            v[pos] = true;
        }
        pos += 1;
        pos = t.find('s', pos);
    }

    //チョキで勝つ
    pos = t.find('p', 0);
    while (pos != string::npos) {
        if(pos<k || !(t[pos-k] == 'p' && v[pos-k])){
            //DEBUG2("s", pos);
            ans += s;
            v[pos] = true;
        }

        pos += 1;
        pos = t.find('p', pos);
    }

    //パーで勝つ
    pos = t.find('r', 0);
    while (pos != string::npos) {
        if(pos<k || !(t[pos-k] == 'r' && v[pos-k]) ){
            //DEBUG2("p", pos);
            ans += p;
            v[pos] = true;
        }

        pos += 1;
        pos = t.find('r', pos);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    priority_queue<double> Q;
    cin>>N;
    for(int i=0;i<N;i++){
        double v;
        cin>>v;
        Q.push(-v);
    }
    for(int i=0;i<N-1;i++){
        double v1,v2;
        v1=Q.top();Q.pop();
        v2=Q.top();Q.pop();
        Q.push((v1+v2)/2.0);
    }
    cout<<-Q.top()<<endl;
}

Measured memory_bytes: 256
q = int(input())
for _ in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())
    dot = (x1 - x0)*(x3 - x2) + (y1 - y0)*(y3 - y2)
    if dot == 0:
        print(1)
    elif ((x1 - x0)**2 + (y1 - y0)**2)*((x3 - x2)**2 + (y3 - y2)**2) == dot**2:
        print(2)
    else:
        print(0)



Measured memory_bytes: 5616
#include <stdio.h>
const int MAX = 200001;
int i, n, p[MAX], a[MAX], ans[MAX];
int cnt, min_y, cur;
int main() {
    scanf("%d", &n);
    for (i = 1; i <= n; ++i) scanf("%d", &p[i]), scanf("%d", &a[p[i]]);
    min_y = n + 2, cur = 0;
    ans[0] = 1;
    for (i = 1; i <= n; ++i) {
        if (min_y > a[i]) min_y = a[i];
        if (n - i + 1 == min_y) {
            cnt = i - cur;
            while (cur < i) ans[++cur] = cnt;
        }
    }
    for (i = 1; i <= n; ++i) printf("%d\n", ans[p[i]]);
    return 0;
}

Measured memory_bytes: 4048
import java.util.*;

public class Main{
  static int[] ans;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int a = 0, b = 0, c = 0, ab = 0;
    for(int i = 0; i < N; i++){
      String S = sc.nextLine();
      int s = S.length();
      for(int j = 0; j < s-1; j++){
        if(S.charAt(j) == 'A' && S.charAt(j+1) == 'B'){
          ab++;
        }
      }
      if(S.charAt(0) == 'B' && S.charAt(s-1) == 'A'){
        c++;
      }else if(S.charAt(0) == 'B'){
        b++;
      }else if(S.charAt(s-1) == 'A'){
        a++;
      }
    }
    int min = Math.min(a, b);
    int D = 0;
    if(c == 0){
      D = min;
    }else{
      if(a + b == 0){
        D = c-1;
      }else{
        D = c + min;
      }
    }
    System.out.println(ab+D);
  }
}

Measured memory_bytes: 41056
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        struct Vector
        {
            int[] values;

            public Vector(int size)
            {
                values = new int[size];
            }

            public int size { get { return values.Length; } }
            public int this[int i]
            {
                get { return values[i]; }
                set { values[i] = value; }
            }
        }

        struct Matrix
        {
            int[] values;
            int nrow;
            int ncol;

            public Matrix(int nrow, int ncol)
            {
                this.nrow = nrow;
                this.ncol = ncol;
                values = new int[nrow * ncol];
            }

            public int row { get { return nrow; } }
            public int col { get { return ncol; } }
            public int this[int irow, int icol]
            {
                get { return values[ncol * irow + icol]; }
                set { values[ncol * irow + icol] = value; }
            }
        }

        static Vector Multiply(ref Matrix lhs, ref Vector rhs)
        {
            if (lhs.col != rhs.size)
            {
                throw new Exception();
            }

            Vector result = new Vector(lhs.row);
            for (int irow = 0; irow < lhs.row; ++irow)
            {
                result[irow] = 0;
                for (int icol = 0; icol < lhs.col; ++icol)
                {
                    result[irow] += lhs[irow, icol] * rhs[icol];
                }
            }

            return result;
        }

        static void Main(string[] args)
        {
            var firstInputLine = Console.In.ReadLine();
            var firstInputs = firstInputLine.Split(new char[] { ' ', '\t', '　' });
            var nrow = int.Parse(firstInputs[0]);
            var ncol = int.Parse(firstInputs[1]);

            var matrix = new Matrix(nrow, ncol);
            var vector = new Vector(ncol);

            for (int irow = 0; irow < nrow; ++irow)
            {
                var inputLine = Console.In.ReadLine();
                var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
                if (inputs.Length != ncol)
                {
                    return;
                }
                for (int icol = 0; icol < ncol; ++icol)
                {
                    matrix[irow, icol] = int.Parse(inputs[icol]);
                }
            }

            for (int icol = 0; icol < ncol; ++icol)
            {
                var inputLine = Console.In.ReadLine();
                vector[icol] = int.Parse(inputLine);
            }

            var result = Multiply(ref matrix, ref vector);

            for (int i = 0; i < result.size; ++i)
            {
                Console.WriteLine(result[i]);
            }
        }
    }
}



Measured memory_bytes: 18000
def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split()))
    c = [1, 1]  # comb(N, n), comb(N - 1, n)
    ans = 0
    for n in range(min(N - 1, K) + 1):
        ans += c[0] * c[1]
        ans %= MOD
        n_inv = mod_inv(n + 1, MOD)
        c[0] *= N - n
        c[0] *= n_inv
        c[0] %= MOD
        c[1] *= N - 1 - n
        c[1] *= n_inv
        c[1] %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 76568
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	unsigned long long X;
	unsigned long long Y;
	unsigned long long A;
	unsigned long long B;
	unsigned long long C;
	cin >> X >> Y >> A >> B >> C;

	vector<unsigned long long> p(A, 0);
	vector<unsigned long long> q(B, 0);
	vector<unsigned long long> r(C, 0);

	for (unsigned long long i = 0; i < p.size(); i++) {
		cin >> p[i];
	}
	for (unsigned long long i = 0; i < q.size(); i++) {
		cin >> q[i];
	}
	for (unsigned long long i = 0; i < r.size(); i++) {
		cin >> r[i];
	}
	sort(p.begin(), p.end(), greater<unsigned long long>());
	sort(q.begin(), q.end(), greater<unsigned long long>());
	sort(r.begin(), r.end(), greater<unsigned long long>());

	vector<unsigned long long> s(X + Y, 0);
	for (unsigned long long i = 0; i < X; i++) {
		s[i] = p[i];
	}
	for (unsigned long long i = X; i < s.size(); i++) {
		s[i] = q[i - X];
	}
	sort(s.begin(), s.end(), greater<unsigned long long>());

	auto itr_s = s.begin();
	auto itr_r = r.begin();
	
	vector<unsigned long long> apple(X + Y, 0);
	for (unsigned long long i = 0; i < apple.size(); i++) {
		if (*itr_r <= *itr_s) {
			apple[i] = *itr_s;
			itr_s += 1;
		}
		else {
			apple[i] = *itr_r;
			itr_r += 1;
		}
	}

	unsigned long long ans = accumulate(apple.begin(), apple.end(), (unsigned long long)0);

	cout << ans << endl;

}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    cout << a*b << '\n';
}









Measured memory_bytes: 3644
($N,$C)=glob<>;
@D=map[split$",<>],1..$C;
for(<>){
	$j=0;
	for$x(split){
		$k=($i+$j)%3;
		for(0..$C-1){
			$_[$k][$_]+=$D[$x-1][$_]
		}
		++$j
	}
	++$i
}
$\=1e15;
for$i(0..$C-1){
	for$j(0..$C-1){
		for(0..$C-1){
			$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$_[0][$i]-$_[1][$j]-$_[2][$_]
		}
	}
}
print


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include<math.h>
#include<map>
#include<vector>
#include <tuple>
using namespace std;
long long int gcd(long long int a,long long int b) {
  long long int v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  };
  return v1;
}

long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
int main() {
  long long int A, B, C, D;
  cin >> A >> B >> C >> D;
  long long int diff = B - A + 1;
  long long int two_r = A % C;
  if(two_r == 0){
    two_r = C;
  }
  long long int three_r = A % D;
  if(three_r == 0){
    three_r = D;
  }

  long long int E = lcm(C, D);
  long long int six_r = A % E;
  if(six_r == 0){
    six_r = E;
  }

  long long int num_two = (diff - C + two_r) / C;
  if((diff - C + two_r) % C > 0){
    num_two++;
  }
  long long int num_three = (diff - D + three_r) / D;
  if((diff - D + three_r) % D > 0){
    num_three++;
  }
  long long int num_six = (diff - E + six_r) / E;
  if((diff - E + six_r) % E > 0){
    num_six++;
  }
  long long int sum = diff - (num_two + num_three - num_six);
  cout << sum << endl;
  return 0;
}


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

int main() {
  string S;
  int K;
  int64_t Q=998244353;
  cin>>S>>K;
  vector<int> p;
  int a=0,P=0,V=S.size();
  for(int i=0;i<V;i++){
    if(S.at(i)=='1'){
      a++;
      P++;
    }
    else{
      p.push_back(a);
      a=0;
    }
  }
  int N=p.size();
  K=min(K,P);
  vector<vector<vector<int64_t>>> dp(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> yr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> tr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      yr[j][j][i]=dp[j][j][i];
      tr[K-j][0][i]=dp[K-j][0][i];
      for(int k=j;k<K;k++){
        yr[k+1][j][i]=(yr[k][j][i]+dp[k+1][j][i])%Q;
        tr[K-j][k+1-j][i]=(tr[K-j][k-j][i]+dp[K-j][k+1-j][i])%Q;
      }
    }
    int b=p[i];
    for(int j=0;j<=K;j++){
      for(int k=0;k<=j;k++){
        int64_t X=0,Y=0;
        if(k-b-1>=0){
          X=tr[j][k-b-1][i];
        }
        if(j-P+b-1>=0){
          Y=yr[j-P+b-1][k][i];
        }
        dp[j][k][i+1]=(tr[j][k][i]+yr[j][k][i]-dp[j][k][i]-X-Y+3*Q)%Q;
      }
    }
  }
  int64_t Z=0;
  for(int j=0;j<=K;j++){
    for(int i=j;i<=min(K,j+a);i++){
      Z+=dp[i][j][N];
      Z%=Q;
    }
  }
  cout<<Z<<endl;
}

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

// dp[len][left]: data[left, left+ len) における max (手番側の得点)-(非手番側の得点) とおくと
// dp[len+1][left]= max(data[left]- dp[len][left+1], data[left+len]- dp[len][left])
// 以上を len in [1,N) についてインライン更新していく。
int main(){
  size_t N;
  cin >> N;

  vector<int64_t> data(N);
  for(size_t i=0; i<N; i++){
    cin >> data.at(i);
  }

  vector<int64_t> dp= data;
  while(dp.size() > 1){
    size_t len= N- dp.size()+ 1;
    vector<int64_t> dp_next;
    for(int left=0; left+len<N; left++){
      int64_t elem= max(data.at(left)- dp.at(left+1), data.at(left+len)- dp.at(left));
      dp_next.emplace_back(elem);
    }

    dp= dp_next;
  }

  cout << dp.at(0) << endl;
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
	int n,num,next=1,count=0;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
    	cin>>num;
		a.push_back(num);
    }
	while(next!=2){
    	next=a[next-1];
		count+=1;
		if(count>=n){
        	count=-1;
			break;
        }
    }
	cout<<count;
}

Measured memory_bytes: 892
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    ans=["" for _ in range(N)]

    for i0,i1 in (("S","S"),("W","S"),("S","W"),("W","W")):
        f=0
        ans[0]=i0
        ans[1]=i1
        for i in range(2,N):
            #print(s[i-1],ans[i-1])
            if (s[i-1]=="o" and ans[i-1]=="S") :
                ans[i]=ans[i-2]
            elif (s[i-1]=="x" and ans[i-1]=="W"):
                ans[i]=ans[i-2]
            else:
                if ans[i-2]=="W": ans[i]="S"
                else:ans[i]="W"
        #print(ans)

        if (ans[-1]=="S" and s[-1]=="o" and ans[-2]==ans[0]) or (ans[-1]=="S" and s[-1]=="x" and ans[-2]!=ans[0]) or (ans[-1]=="W" and s[-1]=="o" and ans[-2]!=ans[0]) or (ans[-1]=="W" and s[-1]=="x" and ans[-2]==ans[0]):
            if (ans[0]=="S" and s[0]=="o" ) or (ans[0]=="W" and s[0]=="x"):
                if ans[-1]==ans[1]:
                    f=1
            else:
                if ans[-1]!=ans[1]:
                    f=1
        
        if f:
            print("".join(ans))
            return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 83384
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main (string[] args) {
        var inp = Console.ReadLine().Split(' ');

        int n = int.Parse(inp[0]);

        if((n % 100) % 10 == 7) {
            Console.WriteLine("Yes");
            return;
        }

        if((n / 10) % 10 == 7) {
            Console.WriteLine("Yes");
            return;
        }

        if(n / 100 == 7) {
            Console.WriteLine("Yes");
            return;
        }

        Console.WriteLine("No");

    }
}

Measured memory_bytes: 27536
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A[200000];

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

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

	sort(A, A+N, greater<int>());

	ll ans = 0;
	priority_queue<int> pq;

	pq.push(A[0]);
	for (int i=1; i<N; i++) {
		if (A[i] == pq.top()) {
			ans += A[i];
			pq.push(A[i]);
		} else {
			ans += pq.top();
			pq.pop();
			pq.push(A[i]);
			pq.push(A[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<bool>> e(n,vector<bool>(n,0));
    vector<ll> a(m),b(m);
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--; b[i]--;
        e[a[i]][b[i]]=1;
        e[b[i]][a[i]]=1;
    }
    ll ans=0;
    rep(i,m){
        e[a[i]][b[i]]=e[b[i]][a[i]]=0;
        queue<ll> q;
        vector<bool> isv(n,0);
        q.push(0);
        isv[0]=1;
        ll cnt=1;
        while(!q.empty()){
            ll now=q.front(); q.pop();
            rep(j,n){
                if(e[now][j]&&!isv[j]){
                    isv[j]=1;
                    q.push(j);
                    cnt++;
                }
            }
        }
        ans+=(cnt==n);
        e[a[i]][b[i]]=e[b[i]][a[i]]=1;
    }
    cout<<m-ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int N=2005;
const int M=4005;
int n,i,k,u,v;
int h[N],nx[M],to[M],cnt;
int f[N][N],g[N][N],ans;
void addedge(int u,int v)
{
	cnt++;
	to[cnt]=v;
	nx[cnt]=h[u];
	h[u]=cnt;
}
void up(int u,int p)
{
	f[u][0]=1;
	for (int i=h[u];i;i=nx[i])
		if (to[i]!=p)
		{
			up(to[i],u);
			for (int j=0;f[to[i]][j];j++)
				f[u][j+1]+=f[to[i]][j];
		}
}
void down(int u,int p)
{
	for (int j=0;f[u][j];j++)
		g[u][j]+=f[u][j];
	for (int i=h[u];i;i=nx[i])
		if (to[i]!=p)
		{
			for (int j=0;g[u][j];j++)
				g[to[i]][j+1]+=g[u][j]-(j-1>=0?f[to[i]][j-1]:0);
			down(to[i],u);
		}
}
void getans(int u,int p)
{
	if ((k&1)^1)
	{
		int t=0;
		for (int i=0;i<=k/2;i++)
			t+=g[u][i];
		if (n-t<ans)
			ans=n-t;
	}
	for (int i=h[u];i;i=nx[i])
		if (to[i]!=p)
		{
			getans(to[i],u);
			if (k&1)
			{
				int t=0;
				for (int j=0;j<=k/2;j++)
					t+=f[to[i]][j];
				for (int j=0;j<=k/2;j++)
					t+=g[u][j]-(j-1>=0?f[to[i]][j-1]:0);
				if (n-t<ans)
					ans=n-t;
			}
		}
}
int main()
{
	scanf("%d%d",&n,&k);
	for (i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	ans=n;
	up(1,0);
	down(1,0);
	getans(1,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

// #include "competitive_helper.cpp"

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

string s, t;
int n;

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    cin >> n;
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        cout << s[i] << t[i];
    }
    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    A = list(map(int, input().split()))
    allB = 3**n
    exc = 1
    for i in range(n):
        if A[i]%2 == 0:
            exc *= 2
    ans = allB - exc
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
def I(): return int(input())
N = I()
ans = 0
a = [N]
set_a ={N}
i = 0
while 1:
    i += 1
    if a[i-1]%2==0:
        a.append(a[i-1]//2)
    else:
        a.append(a[i-1]*3+1)
    if a[i] in set_a:
        print(i+1)
        break
    else:
        set_a.add(a[i])


Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    int n, m;
    vector<int> x;

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        x.push_back(a);
    }

    if(n >= m){
        cout << 0 << endl;
        return 0;
    }

    sort(x.begin(), x.end());
    
    int a = 0;
    if(m == 1){
        a = 0;
    }
    else{
        a = x[m-1] - x[0];
    }
    // cout << a << endl;
    vector<int> y;

    if(m == 1){
        y.push_back(x[0]);
    }
    else{
        for(int i = 0; i < m-1; i++){
            y.push_back(x[i+1] - x[i]);
        }
    }

    sort(y.rbegin(), y.rend());

    /*
    if(m == 1){
        cout << y[0] << endl;
    }
    else{
        for(int i = 0; i < m-1; i++){
            cout << y[i] << endl;
        }
    }
    */

    for(int i = 0; i < n-1; i++){
        a -= y[i];
    }

    cout << a << endl;

    return 0;
}

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

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

    vector<vi> open(n,vi(10));
    rep(i,n) rep(j,10) cin >> open[i][j];

    vector<vi> profit(n,vi(11));
    rep(i,n) rep(j,11) cin >> profit[i][j];

    ll ans=-1e9;
    for(int i=1;i<(1<<10);i++){
        ll prof=0;
        //shop j
        for(int j=0;j<n;j++){
            int cnt=0;
            //day k
            for(int k=0;k<10;k++){
                if(i>>k&open[j][k]){
                    cnt++;
                }
            }
            prof+=profit[j][cnt];
        }
        ans=max(ans,prof);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include<iostream>

#define int long long
using namespace std;

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

const long long MOD = 1e9 + 7;

long long a, b, x;

signed main()
{	
    cin >> a >> b >> x;
    cout << (b / x) - ((a + x - 1) / x) + 1;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m; cin >> n >> m;
    vector<ll> A(n);
    rep(i,n) cin >> A[i];
    
    priority_queue<pair<ll,ll>> nums;
    rep(i,n) nums.push(make_pair(A[i], 1));
    
    rep(i,m){
        ll b,c; cin >> b >> c;
        nums.push(make_pair(c, b));
    }
    
    
    ll ans = 0;
    rep(i,n){
        ll top_first = nums.top().first;
        ll top_second= nums.top().second;
        
        nums.pop();
        
        ans += top_first;
        top_second--;
        if(top_second) nums.push(make_pair(top_first, top_second));
        
    }
    
    cout << ans << endl;
    
}



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



Measured memory_bytes: 7024