akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    string S;
    cin >> S;
    ll count=0;
    rep(i,S.size()){
        if(S[i]=='R'){
            count++;
        }
    }
    if(count==3){
        cout << 3 << endl;
    }
    else if(count==1){
        cout << 1 << endl;
    }
    else if(count==0){
        cout << 0 << endl;
    }
    else{
        if(S[0]=='R' && S[1]=='R'){
            cout << 2 << endl;
        }
        else if(S[1]=='R' && S[2]=='R'){
            cout << 2 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
}

Measured memory_bytes: 3652
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main()
{
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
    {
        s = s + "es";
    }
    else
    {
        s = s + 's';
    }
    cout << s;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
 
typedef struct{
  int value;
  char pattern;
}Card;
 
void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
  
void BubbleSort(Card *c, int n){
 
  int i,j;
  Card tmp;
 
  for(i = 0 ; i <= n-1 ; i++){
    for(j = n-1 ; j > i ; j--){
      if(c[j].value < c[j-1].value){
    tmp = c[j];
    c[j] = c[j-1];
    c[j-1] = tmp;
      }
    }
  }
 
  return;
 
}
 
 
void SelectionSort(Card *c, int n){
 
  int i,minj,j;
  Card tmp;
 
  for(i = 0 ; i <= n-1 ; i++){
    minj = i;
    for(j = i ; j <= n-1 ; j++){
      if(c[j].value < c[minj].value){ 
    minj = j;
      }
    }
    tmp = c[i];
    c[i] = c[minj];
    c[minj] = tmp;
     
  }
 
  return;
 
}
int main(void){
 
  int n,i,flagb=1,flags=1;
  Card cb[36],cs[36];
  char tmp;
 
  scanf("%d%c",&n,&tmp);
 
  for(i = 0 ; i < n ; i++)
    scanf("%c%d%c",&cb[i].pattern,&cb[i].value,&tmp);
 
   
  for(i = 0 ; i < n ; i++){
    cs[i] = cb[i];
  }
 
  SelectionSort(cs, n);
  BubbleSort(cb, n);
 
  for(i = 0 ; i < n ; i++){
    printf("%c%d",cb[i].pattern,cb[i].value);
    if(i!=n-1) printf(" ");
    if(cb[i].pattern != cb[i].pattern || cb[i].value != cb[i].value) flagb=0;
 
  }
 
  printf("\n");
 
  if(flagb==1) printf("Stable\n");
  else printf("Not stable\n");
 
 for(i = 0 ; i < n ; i++){
    printf("%c%d",cs[i].pattern,cs[i].value);
    if(i!=n-1) printf(" ");
    if(cs[i].pattern != cb[i].pattern || cs[i].value != cb[i].value) flags=0;
  }
 
  printf("\n");
 
  if(flags==1) printf("Stable\n");
  else printf("Not stable\n");
 
  return 0;
}
 

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
int a[10],x;
char c;
int main(void)
{
    while(cin>>c&&c!='\0')
    {
        if(c=='0')
a[x++]=0;
        else if(c=='1')
a[x++]=1;
        else
        {
            if(x) x--;
        }
    }
    if(x)
    {
        for(int i=0;i<x;i++)
printf("%d",a[i]);
        printf("\n"); 
    }
}

Measured memory_bytes: 256
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int A, B;
        A = Integer.parseInt (arr[0]);
        B = Integer.parseInt (arr[1]);
        System.out.println (2 * B < A ? A - 2 * B : 0);
        return;
    }
}

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

int main() {
  for (int i = 1; i <= 10000; i ++) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      break;
    } else {
      if (x > y) swap(x, y);
      cout << x << " " << y << endl;
    }
  }
}



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

int main() {
	int n ,team1 ,team2 ,score1 ,score2 ,a[100]={} ,save[100]={};
	cin>>n;
	for(int i=0;i<(n*(n-1)/2);i++){
		team1=0;
		team2=0;
		score1=0;
		score2=0;
		cin>>team1>>team2>>score1>>score2;
		if(score1>score2){
			a[team1]+=3;
		}
		else if(score1<score2){
			a[team2]+=3;
		}
		else if(score1==score2){
			a[team1]++;
			a[team2]++;
		}
	}
	for(int i=1;i<=n;i++){
		save[i]=a[i];
	}
	sort(a,a+n+1);
	for(int i=1;i<=n;i++){
		for(int l=1;l<=n;l++){
				if(a[l]==save[i]){
				if(a[l]==a[l+1]){
					
				}
				else{
						cout<<n-l+1<<endl;
						break;
				}	
			}
		}
	}

return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i=1;i<=n;i++) {
            for (int j=1;j<=n;j++) {
                for (int k=1;k<=n;k++) {
                    int a=i;
                    int b=j;
                    int c=k;
                    int d=0;
                    while (a%b>0) {
                        if (a<b) {
                          d=b;
                          b=a;
                          a=d;
                        } else {
                            a=a%b;
                        }
                    }
                    while (b%c>0) {
                        if (b<c) {
                            d=c;
                            c=b;
                            b=d;
                        } else {
                            b=b%c;
                        }
                    }
                    ans+=c;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35832
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

long int W = 1e+9+7;
int main(void){
    long int x;
    cin >> x;
    int w_x = x%11,sum=0;
    long int count=x/11*2;
    while(true){
        if(sum >= w_x){
            break;
        }
        sum+=6;
        count++;
        if(sum >= w_x){
            break;
        }
        sum+=5;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
//MIPT Cryptozoology 17.2
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
    //assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
    //freopen(FILENAME ".in", "r", stdin);
    //freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
    cout.sync_with_stdio(0);
    cin.tie(0);
#endif
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        //cerr << testNum << endl;
        solve(true);
        //cerr << testNum - 1 << endl;
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    auto end = clock();

    usleep(10000);
    print_stats(end - start);
    usleep(10000);
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

//#define int li
//const int mod = 1000000007;

template<typename T>
void relax_max(T& cur, T val) {
    cur = max(cur, val);
}

const int C = 303;
int dp[C][C][C];

void solve(__attribute__((unused)) bool read) {
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int r = 0; r <= n; ++r) {
                dp[i][j][r] = -(int)1e9;
            }
        }
    }
    dp[0][n - 1][0] = 0;
    int res = 0;
    for (int l = 0; l < n; ++l) {
        for (int r = n - 1; r >= 0 && r >= l - 1; --r) {
            for (int used = 0; used <= k; ++used) {
                if (r < l) {
                    relax_max(res, dp[l][r][used]);
                    continue;
                }
                //cout << l << " " << r << " " << used << " " << dp[l][r][used] << endl;
                relax_max(res, dp[l][r][used] + 1);
                relax_max(dp[l + 1][r][used], dp[l][r][used]);
                if (r > 0) {
                    relax_max(dp[l][r - 1][used], dp[l][r][used]);
                }
                if (l < r) {
                    if (s[l] == s[r]) {
                        relax_max(dp[l + 1][r - 1][used], dp[l][r][used] + 2);
                    }
                    relax_max(dp[l + 1][r - 1][used + 1], dp[l][r][used] + 2);
                }
            }
        }
    }

    cout << res << endl;

}

Measured memory_bytes: 108800
#include <stdio.h>
#include <stdlib.h>
#define NMAX 100000
int compare(const void *a, const void *b);
int main(void)
{
  while (1) {
    int i, d, n, m, k, ans = 0, dis[NMAX+1];
    scanf("%d", &d);
    if (!d) break;
    scanf("%d %d", &n, &m);
    dis[0] = 0;
    dis[n] = d;
    for (i = 1; i < n; i++) scanf("%d", &dis[i]);
    qsort(dis, n + 1, sizeof(int), compare);
    for (i = 0; i < m; i++) {
      int lo = 0, hi = n;
      scanf("%d", &k);
      while (hi >= lo) {
        int mid = (lo + hi) / 2;
        if (dis[mid] > k) hi = mid - 1;
        else lo = mid + 1;
      }
      if (k - dis[hi] < dis[lo] - k) ans += k - dis[hi];
      else ans += dis[lo] - k;
    }
    printf("%d\n", ans);
  }
}

int compare(const void *a, const void *b)
{
  int ta = *(int*)a, tb = *(int*)b;                                                                                       return ta - tb;
}


Measured memory_bytes: 2460
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define MAX_N 10000000
#define ll int64_t
#define all(v) (v).begin(),(v).end()
#define P pair<int,int>
using namespace std;

int main() {
  vector<P> meal(5);
  rep(i,5) {
    cin>>meal[i].second;
    meal[i].first=(meal[i].second)%10;
    if(meal[i].first==0)
    meal[i].first=10;
  }
  sort(all(meal));
  int count=0;
  for(int i=1;i<5;i++) {
    if(meal[i].second%10!=0)
    count+=meal[i].second-meal[i].second%10+10;
    else count+=meal[i].second;
  }
  count+=meal[0].second;
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
five = 0
seven =0
if a == 5:
  five = five + 1;
elif a == 7:
  seven = seven + 1;
if b == 5:
  five = five + 1;
elif b == 7:
  seven = seven + 1;
if c == 5:
  five = five + 1;
elif c == 7:
  seven = seven + 1;
if five == 2 and seven == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] in_array = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            bool[] check = new bool[5];

            for (int i = 0; i < 5; i++)
            {
                if (in_array[i] != 0)
                {
                    check[in_array[i] - 1] = true;
                }
            }
            for (int i = 0; i < 5; i++)
            {
                if (!check[i])
                {
                    Console.WriteLine(i + 1);
                }
            }
        }
    }
}


Measured memory_bytes: 28080
N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)
ans = 0
i = 0
while M > 0:
  M -= dic[List[i]]
  ans = List[i]
  i += 1
print(ans)

Measured memory_bytes: 16324
#include<bits/stdc++.h>
using namespace std;
int main(void){
   int i,n,x;
   string s;
   std::cin >> s;
   if(s[0]==s[1]){
       if(s[2]==s[3]&&s[2]!=s[0])std::cout << "Yes" << std::endl;
       else std::cout << "No" << std::endl;
   }
    else if(s[0]==s[2]){
       if(s[1]==s[3]&&s[1]!=s[0])std::cout << "Yes" << std::endl;
       else std::cout << "No" << std::endl;
   }
   else if(s[0]==s[3]){
       if(s[1]==s[2]&&s[1]!=s[0])std::cout << "Yes" << std::endl;
       else std::cout << "No" << std::endl;
   }
   else std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>p(N);
    for(int i = 0; i < N; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(i+1 == p[i]) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3988
n = int(input())
a=[]
for i in range(n):
  a.append(int(input()))
s=sum(a)
n10 =[i for i in a if i %10 != 0]

if s % 10 != 0:
  print(s)
elif n10:
  print(s-min(n10))
else:
  print(0)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int s(int n) {
    int ans = 0;

    while (n) {
        ans += n % 10;
        n /= 10;
    }

    return ans;
}

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

    if (n % s(n) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecInt(A, N);
    sort(A.begin(), A.end());
    vector<int> B(N);
    ll result = 0;
    if (N % 2 == 0){
        REP(i, N / 2){
            B[i * 2] = A[N / 2 + i];
            B[i * 2 + 1] = A[i];
        }

    }else{
        if (abs(A[N / 2] - A[N / 2 - 1]) < abs(A[N / 2] - A[N / 2 + 1])){
            B[N - 1] = A[N / 2];
            REP(i, N / 2){
                B[i * 2] = A[N / 2 - 1 - i];
                B[i * 2 + 1] = A[N / 2 + 1 + i];
            }
        }else{
            B[N - 1] = A[N / 2];
            REP(i, N / 2){
                B[i * 2] = A[N / 2 + 1 + i];
                B[i * 2 + 1] = A[N / 2 - 1 - i];
            }
        }
    }
    REP(i, N - 1){
        result += abs(B[i] - B[i + 1]);
    }
    cout << result << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	ll m;
	cin>>n>>m;
	int a[100010];
	ll s[100010]; s[0]=0;
	for(int i=0; i<n; i++) cin>>a[i];
	sort(a, a+n);
	for(int i=0; i<n; i++) s[i+1]=s[i]+a[i];
	int l=0, r=200001;
	while(r-l>1){
		int mid=(l+r)/2;
		ll cnt=0;
		for(int i=0; i<n; i++){
			int k=lower_bound(a, a+n, mid-a[i])-a;
			cnt+=n-k;
		}
		if(cnt>=m) l=mid;
		else r=mid;
	}
	ll ans=0;
	ll cnt=0;
	for(int i=0; i<n; i++){
		int k=lower_bound(a, a+n, l+1-a[i])-a;
		cnt+=n-k;
		ans+=s[n]-s[k]+(ll)a[i]*(n-k);
	}
	ans+=(m-cnt)*l;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
package main

import (
	"container/heap"
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	g := make([][]Edge, n+1)
	em := make(map[[2]int]bool)
	var a, b, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b, &c)
		if a > b {
			a, b = b, a
		}

		g[a] = append(g[a], Edge{b, c})
		g[b] = append(g[b], Edge{a, c})
		em[[2]int{a, b}] = true
	}

	for i := 1; i <= n; i++ {
		_, prevs := dijkstra(g, i)
		for j := 1; j <= n; j++ {
			if i == j {
				continue
			}
			ps := path(prevs, j)
			for k := 1; k < len(ps); k++ {
				a, b := ps[k-1], ps[k]
				if a > b {
					a, b = b, a
				}
				em[[2]int{a, b}] = false
			}
		}
	}

	ans := 0
	for _, v := range em {
		if v {
			ans++
		}
	}

	fmt.Println(ans)
}

// Edge .
type Edge struct {
	to, cost int
}

const inf int = 1e10

func dijkstra(g [][]Edge, s int) ([]int, []int) {
	dists := make([]int, len(g))
	for i := 1; i < len(dists); i++ {
		dists[i] = inf
	}
	prevs := make([]int, len(g))

	pq := make(PriorityQueue, 0)
	heap.Init(&pq)
	heap.Push(&pq, &Item{s, 0})
	dists[s] = 0

	for pq.Len() > 0 {
		item := heap.Pop(&pq).(*Item)
		u := item.pos

		if dists[u] < item.cost {
			continue
		}

		for _, e := range g[u] {
			if dists[e.to] > item.cost+e.cost {
				dists[e.to] = item.cost + e.cost
				prevs[e.to] = u
				heap.Push(&pq, &Item{e.to, dists[e.to]})
			}
		}
	}

	return dists, prevs
}

func path(prevs []int, t int) []int {
	path := make([]int, 0)

	for cur := t; cur != 0; cur = prevs[cur] {
		path = append(path, cur)
	}

	return path
}

// Item .
type Item struct {
	pos  int
	cost int
}

// PriorityQueue .
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].cost < pq[j].cost
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

// Push .
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*Item)
	*pq = append(*pq, item)
}

// Pop .
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil
	*pq = old[0 : n-1]
	return item
}


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

int main(){
  int n,count = 0;
  cin >> n;
  vector<int> v(n+2,0);
  r(i,n)cin >> v.at(i);
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  r(i,n/2+1){
    count+=v.at(2*i)-v.at(2*i+1);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> data;

  UnionFind(int sz) { data.assign(sz, -1); }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) { return (-data[find(k)]); }
};

int main() {
  ll n, k, l;
  cin >> n >> k >> l;
  UnionFind uf1(n), uf2(n);

  REP(i, k) {
    ll p, q;
    cin >> p >> q;
    p--, q--;
    uf1.unite(p, q);
  }
  REP(i, l) {
    ll r, s;
    cin >> r >> s;
    r--, s--;
    uf2.unite(r, s);
  }

  map<pair<ll, ll>, ll> mp;
  REP(i, n) {
    ll a = uf1.find(i);
    ll b = uf2.find(i);
    pair<ll, ll> pr = make_pair(a, b);
    mp[pr]++;
  }
  REP(i, n) {
    ll a = uf1.find(i);
    ll b = uf2.find(i);
    pair<ll, ll> pr = make_pair(a, b);
    cout << mp[pr] << " ";
  }

  return 0;
}

Measured memory_bytes: 13568
n=int(input())

a=(n-n%100)//100
b=(n-a*100-n%10)//10
c=n%10

if  a>b:
    print(a*100+a*10+a)
elif a<b:
    print((a+1)*100+(a+1)*10+a+1)
else:
    if b>=c:
        print(a*100+a*10+a)
    else:
        print((a+1)*100+(a+1)*10+a+1)

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

int main() {
	char a, b;
	scanf("%c %c", &a, &b);
	
	if (a == 'H') {
		printf("%c", b == 'H' ? 'H' : 'D');
	} else {
		printf("%c", b == 'H' ? 'D' : 'H');
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var idx = Partition(ref arr, 0, arr.Length - 1);
            Console.WriteLine($"{string.Join(" ", arr.Take(idx))} [{arr[idx]}] {string.Join(" ", arr.Skip(idx + 1))}");
        }

        private static int Partition(ref int[] arr, int p, int r)
        {
            var x = arr[r];
            var i = p - 1;
            for(var k = p; k < r; ++k)
            {
                if(arr[k] <= x)
                {
                    ++i;
                    Swap(ref arr[i], ref arr[k]);
                }
            }
            Swap(ref arr[i + 1], ref arr[r]);
            return i + 1;
        }

        private static void Swap(ref int v1, ref int v2)
        {
            var tmp = v1;
            v1 = v2;
            v2 = tmp;
        }
    }
}


Measured memory_bytes: 30584
import sys
sys.setrecursionlimit(10**6)

N = int(input())
s = sorted([int(input()) for i in range(N)])

correct = False
for n in s:
    if n % 10 != 0:
        correct = True
        break

if correct:
    ans_max = sum(s)
    if ans_max % 10 != 0:
        print(ans_max)
    else:
        for i in s:
            if i % 10 != 0:
                print(ans_max-i)
                break
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;



int main()
{
    FAST
    ll n,k;cin>>n>>k;
    ll a[n+1];f(i,1,n+1) cin>>a[i];
    f(i,k+1,n+1)
    {
        ll curr = a[i];
        ll prev = a[i-k];
        if(curr>prev) cout<<"Yes\n";
        else cout<<"No\n";
    }

}


Measured memory_bytes: 5216
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C
 */
#include <iostream>
#include <string>
#include <list>

using namespace std;

int
main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n; cin.ignore();

    list<int> lst;
    for (int i = 0; i < n; i++) {
        string cmd;
        getline(cin, cmd);

        switch (cmd[6]) {
          case 'F':
            lst.pop_front();
            break;
          case 'L':
            lst.pop_back();
            break;
          default:
            int k = stoi(cmd.substr(7));
            if(cmd[0] == 'i') {
                lst.push_front(k);
            } else {
                for (auto it = lst.cbegin(); it != lst.cend(); it++) {
                    if (*it == k) {
                        lst.erase(it);
                        break;
                    }
                }
            }
        }
    }
    for (auto it = lst.begin(); it != lst.end(); it++) {
        if (it != lst.begin()) { cout << ' '; }
        cout << *it;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 34380
n = int(input())
c = 'abcdefghijk'
d = [[0]]
for i in range(n-1):
  pd,d = d,[]
  for j in pd:
    m = max(j)
    for k in range(m+2):
      d.append(j+[k])
for i in d:
  for j in i[:-1]:
    print(c[j],end='')
  print(c[i[-1]])

Measured memory_bytes: 29288
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;


struct UnionFind{
  vector<int> par;
  UnionFind(int N):par(N){
    REP(i,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
};

int main(){
  int H,W;
  cin>>H>>W;
  char S[H][W];
  REP(h,H)REP(w,W){
    cin>>S[h][w];
  }
  UnionFind tree(H*W);
  REP(h,H-1){
    REP(w,W-1){
      if(S[h][w]!=S[h][w+1])tree.unite(W*h+w,W*h+w+1);
      if(S[h][w]!=S[h+1][w])tree.unite(W*h+w,W*(h+1)+w);
    }
  }
  REP(h,H-1)if(S[h][W-1]!=S[h+1][W-1])tree.unite(W*h+W-1,W*(h+1)+W-1);
  REP(w,W-1)if(S[H-1][w]!=S[H-1][w+1])tree.unite(W*(H-1)+w,W*(H-1)+w+1);
  map<int,pair<int,int> >m;
  REP(h,H)REP(w,W){
    if(S[h][w]=='.')m[tree.root(W*h+w)].first+=1;
    else m[tree.root(W*h+w)].second+=1;
  }
  lint ans=0;
  for(auto &e:m){
    ans+=(lint)(e.second.first)*(lint)(e.second.second);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9600
#include <cstdio>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		char mcxi_a[128];
		char mcxi_b[128];
		int sum = 0;
		scanf("%s %s", mcxi_a, mcxi_b);
		
		int i = 0;
		while (mcxi_a[i] != '\0'){
			switch (mcxi_a[i]){
				case 'i':
				if (i > 0 && mcxi_a[i - 1] >= '2' && mcxi_a[i - 1] <= '9'){
					sum += mcxi_a[i - 1] - '0';
				}
				else {
					sum += 1;
				}
				break;
				
				case 'x':
				if (i > 0 && mcxi_a[i - 1] >= '2' && mcxi_a[i - 1] <= '9'){
					sum += (mcxi_a[i - 1] - '0') * 10;
				}
				else {
					sum += 10;
				}
				break;
				
				case 'c':
				if (i > 0 && mcxi_a[i - 1] >= '2' && mcxi_a[i - 1] <= '9'){
					sum += (mcxi_a[i - 1] - '0') * 100;
				}
				else {
					sum += 100;
				}
				break;
				
				case 'm':
				if (i > 0 && mcxi_a[i - 1] >= '2' && mcxi_a[i - 1] <= '9'){
					sum += (mcxi_a[i - 1] - '0') * 1000;
				}
				else {
					sum += 1000;
				}
				break;
			}
			
			i++;
		}
		
		i = 0;
		while (mcxi_b[i] != '\0'){
			switch (mcxi_b[i]){
				case 'i':
				if (i > 0 && mcxi_b[i - 1] >= '2' && mcxi_b[i - 1] <= '9'){
					sum += mcxi_b[i - 1] - '0';
				}
				else {
					sum += 1;
				}
				break;
				
				case 'x':
				if (i > 0 && mcxi_b[i - 1] >= '2' && mcxi_b[i - 1] <= '9'){
					sum += (mcxi_b[i - 1] - '0') * 10;
				}
				else {
					sum += 10;
				}
				break;
				
				case 'c':
				if (i > 0 && mcxi_b[i - 1] >= '2' && mcxi_b[i - 1] <= '9'){
					sum += (mcxi_b[i - 1] - '0') * 100;
				}
				else {
					sum += 100;
				}
				break;
				
				case 'm':
				if (i > 0 && mcxi_b[i - 1] >= '2' && mcxi_b[i - 1] <= '9'){
					sum += (mcxi_b[i - 1] - '0') * 1000;
				}
				else {
					sum += 1000;
				}
				break;
			}
			
			i++;
		}
		
		if (sum / 1000 > 0){
			if (sum / 1000 >= 2 && sum / 1000 <= 9){
				printf("%d", sum / 1000);
			}
			printf("m");
		}
		sum %= 1000;
		if (sum / 100 > 0){
			if (sum / 100 >= 2 && sum / 100 <= 9){
				printf("%d", sum / 100);
			}
			printf("c");
		}
		sum %= 100;
		if (sum / 10 > 0){
			if (sum / 10 >= 2 && sum / 10 <= 9){
				printf("%d", sum / 10);
			}
			printf("x");
		}
		sum %= 10;
		if (sum > 0){
			if (sum >= 2 && sum <= 9){
				printf("%d", sum);
			}
			printf("i");
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll a[3000005],ans=1,k;
void f(ll now,ll cnt)
{
    a[ans]=now;
    ans++;
    if(cnt==11)
    {
        return;
    }
    f(now*10+(now%10), cnt+1);
    if((now%10)-1>=0)
    {
        f( now*10+(now%10)-1, cnt+1);
    }
    if((now%10)+1<=9)
    {
        f( now*10+(now%10)+1, cnt+1);
    }
}
int main()
{
    //IOS;
    cin>>k;
    for(int i=1;i<=9;i++)
    {
        f(i,1);
    }
    //cout<<ans<<endl;
    sort(a+1,a+ans);
    cout<<a[k]<<endl;
    return 0;
}
/*

*/


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> items(N, vector<ll>(M));
    rep(i, N) {
        ll c;
        cin >> c;
        C[i] = c;
        rep(j, M) {
            ll a;
            cin >> a;
            items[i][j] = a;
        }
    }
    ll ans = INF;
    rep(i, 1 << N) {
        ll s = 0;
        vector<ll> cnt(M, 0);
        rep(j, N) {
            if (i & (1 << j)) {
                rep(k, M) {
                    cnt[k] += items[j][k];
                }
                s += C[j];
            }
        }
        bool ok = true;
        rep(x, M) {
            if (cnt[x] < X) {
                ok = false;
            }
        }
        if (ok) {
            ans = min(ans, s);
        }
    }
    if (ans == INF) {
        cout << -1 << '\n';
    }else {
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3660
n, m, x = map(int, input().split())
cas = [list(map(int, input().split())) for i in range(n)]

# 合否判定のためのフラグ
Flag = False
cost_min = 0
for i in range(n):
  cost_min += cas[i][0]

# 全ての組み合わせについてチェック
for i in range(2**n):
  bag  = [0]*(m+1)
  # バッグに荷物を詰める
  for j in range(n):
    if ((i>>j) & 1):
      for k in range(m+1):
        bag[k] += cas[j][k]
  # 条件を満たしているか調べる
  if (min(bag[1:]) >= x):
    Flag = True
    cost_min = min(cost_min, bag[0])

if (Flag):
  print(cost_min)
else:
  print(-1)

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        
        if(a<b){
            System.out.println("a < b");
        }else if(a==b){
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }
        
        
    }
}



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

int main()
{
    string s;
    cin >> s;
    vector<int> rlr(0), res(s.length(), 0);
    for (int i = 0; i < s.length() - 1; i++)
    {
        if (s.at(i) == 'R' && s.at(i + 1) == 'L')
            rlr.push_back(i);
        if (s.at(i) == 'L' && s.at(i + 1) == 'R')
            rlr.push_back(i);
    }
    rlr.push_back(s.length() - 1);
    for (int i = 0; i < rlr.size(); i += 2)
    {
        if (i == 0)
        {
            if (rlr.at(i + 1) % 2)
            {
                res.at(rlr.at(i)) = (rlr.at(i + 1) + 1) / 2;
                res.at(rlr.at(i) + 1) = res.at(rlr.at(i));
            }
            else
            {
                res.at(rlr.at(i)) = rlr.at(i + 1) / 2;
                res.at(rlr.at(i) + 1) = res.at(rlr.at(i));
                if (rlr.at(i) % 2)
                    res.at(rlr.at(i) + 1)++;
                else
                    res.at(rlr.at(i))++;
            }
        }
        else
        {
            int wid = rlr.at(i + 1) - rlr.at(i - 1) - 1, bas = rlr.at(i) - rlr.at(i - 1) - 1;
            if (wid % 2)
            {
                res.at(rlr.at(i)) = (wid + 1) / 2;
                res.at(rlr.at(i) + 1) = res.at(rlr.at(i));
            }
            else
            {
                res.at(rlr.at(i)) = wid / 2;
                res.at(rlr.at(i) + 1) = res.at(rlr.at(i));
                if (bas % 2)
                    res.at(rlr.at(i) + 1)++;
                else
                    res.at(rlr.at(i))++;
            }
        }
    }
    for (int i = 0; i < res.size() - 1; i++)
        std::cout << res.at(i) << " ";
    std::cout << res.back() << endl;
}

Measured memory_bytes: 1528
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def cal(x, y, z):
	return (x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x)

#処理内容
def main():
	N = int(input())
	D = defaultdict(int)
	for i in range(1, 101):
		for j in range(1, 101):
			for k in range(1, 101):
				val = cal(i, j, k)
				D[val] += 1

	for i in range(1, N + 1):
		print(D[i])


if __name__ == '__main__':
	main()

Measured memory_bytes: 72684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int W, H, N;
	cin >> W >> H >> N;
	
	int A[100][100] = {};
	rep(i, N) {
		int x, y, a;
		cin >> x >> y >> a;

		if (a == 1) {
			rep(i1, H) {
				rep(i2, x) A[i2][i1] = 1;
			}
		}
		else if (a == 2) {
			rep(i1, H) {
				rep(i2, W - x) A[W - i2 - 1][i1] = 1;
			}
		}
		else if (a == 3) {
			rep(i1, W) {
				rep(i2, y) A[i1][i2] = 1;
			}
		}
		else if (a == 4) {
			rep(i1, W) {
				rep(i2, H - y) A[i1][H - i2 - 1] = 1;
			}
		}
	}

	int kotae = H * W;
	rep(i, W) {
		rep(ii, H) {
			kotae -= A[i][ii];
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    if(n == 1 || n == 2 || n == 3 || n == 5 || n == 6 ||
       n == 9 || n == 10 || n == 13 || n == 17) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
    
}


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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int c=1;
    int cnt=0;
    while(c<b){
        c+=(a-1);
        cnt++;
    }
    
    cout<<cnt<<endl;
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, k; cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}

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

struct ops{
  int pos,num;
  char op;
  ops(int pos, int num, char op):pos(pos),num(num),op(op){}
  bool operator < (const ops &p) const {
    return pos < p.pos;
  }
};

string str;

void print(const vector<ops> &v){
  for(int i=0;i<v.size();i++){
    if(v[i].op == 0) cout << v[i].num;
    else cout << v[i].op;
  }
  cout << endl;
}

void erase_parenthesis(vector<ops> &v){
 for(int i=0;i<(int)v.size()-2;i++){
    if(v[i].op == '(' && v[i+1].op == 0 && v[i+2].op == ')'){
      v.erase(v.begin() + i + 2);
      v.erase(v.begin() + i);
      i--;
      if(i >= 0) i--;
    }      
  }

}

int solve(){
  set<int> st;
  vector<ops> ov,initv;

  for(int i=0;i<str.size();i++){
    if(str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/'){
      initv.push_back(ops(i, 0, str[i]));
      ov.push_back(ops(i, 0, str[i]));
    } else if(str[i] >= '0' && str[i] <= '9'){
      int num = 0;
      while(str[i] >= '0' && str[i] <= '9'){
        num *= 10;
        num += str[i] - '0';
        i++;
      }
      i--;
      initv.push_back(ops(i, num, 0));
    } else {
      initv.push_back(ops(i, 0, str[i]));
    }
  }

  erase_parenthesis(initv);
  if(initv.size() == 1 && initv[0].op == 0) return 1;

  do{
    vector<ops> v = initv;
    for(int i=0;i<ov.size();i++){
      int pos = lower_bound(v.begin(), v.end(), ov[i]) - v.begin(), res;
      if(pos <= 0 || pos >= v.size()-1 || v[pos-1].op != 0 || v[pos+1].op != 0) break;
      if(v[pos].op == '/' && v[pos+1].num == 0) break;
      if(v[pos].op == '+') res = v[pos-1].num + v[pos+1].num;
      if(v[pos].op == '-') res = v[pos-1].num - v[pos+1].num;
      if(v[pos].op == '*') res = v[pos-1].num * v[pos+1].num;
      if(v[pos].op == '/') res = v[pos-1].num / v[pos+1].num;
      for(int j=0;j<2;j++) v.erase(v.begin()+pos);
      v[pos-1].num = res;

      erase_parenthesis(v);
    }

    if(v.size() == 1 && v[0].op == 0) st.insert(v[0].num);

  } while(next_permutation(ov.begin(), ov.end()));

  return max(1, (int)st.size());
}

int main(){
  while(cin >> str && str != "#") cout << solve() << endl;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> l(N);
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}

	sort(l.begin(), l.end(), greater<int>());
	int ret = 0;
	for (int i = 0; i < K; i++) {
		ret += l[i];
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int64 n;
    cin >> n;
    vector x(n, 0LL);
    vector y(n, 0LL);
    for (int i=0; i<n; i++) cin >> x[i] >> y[i];

//    debug(x);
//    debug(y);

    int64 _max1 = INT_MIN;
    int64 _min1 = INT_MAX;
    for (int i=0; i<n; i++) _max1 = max(_max1, x[i] - y[i]);
    for (int i=0; i<n; i++) _min1 = min(_min1, x[i] - y[i]);

    int64 _max2 = INT_MIN;
    int64 _min2 = INT_MAX;
    for (int i=0; i<n; i++) _max2 = max(_max2, x[i] + y[i]);
    for (int i=0; i<n; i++) _min2 = min(_min2, x[i] + y[i]);

    cout << max(_max1 - _min1, _max2 - _min2) << endl;

}

Measured memory_bytes: 6048
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
signed main() {
    int N;
    cin>>N;
    int A=0;

    for(int i=1;i<=N;i+=2){
        const auto &res = enum_divisors(i);
        if(res.size()==8){
            A++;
        }
    }
    cout<<A<<endl;
}


Measured memory_bytes: 3524
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
visited = set([p])

for _ in range(N):
    p = A[p]
    if p in visited:
        break
    points.append(p)
    visited.add(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

cycle = points[idx:]

print(cycle[(K - idx) % len(cycle)])

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        vector<long> a(n);
        umap<long, long> di, dj;
        for (long i = 0; i < n; i++) {
            cin >> a[i];
            di[a[i] + i + 1]++;
            dj[i + 1 - a[i]]++;
        }
        long ans = 0;
        for (auto &p : di) {
            long count = p.second * dj[p.first];
            ans += count;
        }
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 27872
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define MAX_V 1001
#define MAX_E 2001
#define INF (1e9 + 1)

using namespace std;

struct edge{
  int from,to,cost;
};
vector<edge> edges;

int V,E,r,a,b,c;
int d[MAX_V];

void bellford(){
  REP(i,MAX_V) d[i] = INF;
  d[r] = 0;
  REP(i,V){
    bool update = false;
    REP(j,E){
      edge e = edges[j];
      if(d[e.from] != INF && d[e.from]+e.cost < d[e.to]){
        update = true;
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1){
          cout << "NEGATIVE CYCLE" << endl;
          return;
        }
      }
    }
    if(!update)break;
    }

    REP(i,V){
      if(d[i]==INF)cout << "INF"<<endl;
      else cout << d[i] << endl;
    }
}


int main(){
  scanf("%d %d %d",&V,&E,&r);
  REP(i,E){
    scanf("%d %d %d",&a,&b,&c);
    edges.push_back((edge){a,b,c});
  }
  bellford();
}



Measured memory_bytes: 3256
f=lambda:map(int,input().split())
n,m=f()
g=[[0]*n for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1][b-1]=1
  g[b-1][a-1]=1
from itertools import *
p=[*permutations(range(1,n))]
a=0
for t in p:
  v=0
  for c in t:
    if g[v][c]: v=c
    else: break
  else: a+=1
print(a)

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

int S[50];
int fib(int N){
    if(N==0||N==1) return S[N]=1;
    if(S[N]!=0) return S[N];
    return S[N]=fib(N-1)+fib(N-2);
}

int main(){

    int N;
    cin>>N;
    cout<<fib(N)<<endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
 
  cin >> A >> B >> C >> D;
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  else if (A + B < C + D){
    cout << "Right" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const N_MAX = 3010;
ll dp[N_MAX][N_MAX];

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N_MAX; i++) {
    for (int j = 0; j < N_MAX; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    for (int j = i; j < N; j++) {
      if ((N - 1 - j - i) % 2 == 0) {
        dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j]);
      } else {
        dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j]);
      }
    }
  }
  ll ans = dp[0][N - 1];
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    vector<vector<int>> mp(n);

    int l, r;

    for(int i = 0; i < m; ++i) {
        cin >> l >> r;
        mp.at(l - 1).push_back(r);
        mp.at(r - 1).push_back(l);
    }

    vector<int> p(n);
    vector<int> tmp = {1}, tmp2;
    int room = n - 1;
    p.at(0) = -1;

    while(tmp.size() != 0) {
        tmp2 = tmp;
        tmp = {};
        for(int i: tmp2) {
            for(int j: mp.at(i - 1)) {
                if(p.at(j - 1) == 0) {
                    tmp.push_back(j);
                    p.at(j - 1) = i;
                }
            }
        }
        for(int i: tmp) --room;
    }

    if(room != 0) printf("No\n");
    else {
        printf("Yes\n");
        for(int i = 1; i < n; ++i) printf("%d\n", p.at(i));
    }
    
    return 0;
}

Measured memory_bytes: 10712
import fractions
a,b,c,d= map(int, input().split())

def lcm(x, y):  #最小公倍数
    return (x * y) // fractions.gcd(x, y)

def cnt(n,x,y):
    return n-n//x-n//y+n//lcm(x,y)
  
print(cnt(b,c,d)-cnt(a-1,c,d))

Measured memory_bytes: 5048