akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
// SZ = 1e6 だと10ms
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    auto fn = [&]() {
        REP(i, SZ) {
            // 素数の場合
            if (prime.b[i]) {
                int cnt = 0;
                for (int now = i; now <= SZ; now += i) {
                    cnt += D[now];
                    // 共通の素数を含むのでgcd(ALL) >= i
                    if (cnt >= 2) {
                        return false;
                    }
                }
            }
        }
        return true;
    };
    // trueなら "pairwise coprime"
    if (fn()) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 19048
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ret = false;
    for(int i=0;i<s.length();++i)
    {
        if(s[i] == '7')
        {
            ret = true;
        }
    }

    cout << (ret ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 3612
a,b,m = map(int,input().split())

al = list(map(int,input().split()))
bl = list(map(int,input().split()))

ans = min(al)+ min(bl)
temp = 0

for i in range(m):
  x,y,c =  map(int,input().split())
  temp = al[x-1] + bl[y-1] - c
  if temp < ans:
    ans = temp
print(ans)
    

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w,a,b;
  cin >> w >> a >> b;
  if(a-b-w>0)
    cout << a-b-w << endl;
  else if(b-a-w>0)
    cout << b-a-w << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int r, c, a[101][101] = {0};
    scanf("%d %d", &r, &c);
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            a[i][c] = a[i][c] + a[i][j];
            a[r][j] = a[r][j] + a[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        a[r][c] = a[r][c] + a[i][c];
    }
    for (int i = 0; i < r + 1; i++)
    {
        for (int j = 0; j < c + 1; j++)
        {
            if (j == 0)
            {
                printf("%d", a[i][j]);
            }
            else
            {
                printf(" %d", a[i][j]);
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2048
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = [a - i for i, a in enumerate(A, start=1)]
    A.sort()
    b = A[N//2]
    print(sum([abs(a - b) for a in A]))


if __name__ == '__main__':
    main()


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{



    lint n;
    cin >> n;

    lint ans=0, tmp=1;

    vector<string> s(n);
    REP(i, n) { 
        cin >> s[i];
        sort(ALL(s[i]));
    }
    sort(ALL(s));

    REP(i, n-1){
    }

    REP(i, n-1)
    {
        if(s[i]==s[i+1]){
            tmp += 1;
        }else{
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;
        }
      //  cout << s[i]<< tmp << "\n";
    }

    ans += tmp * (tmp - 1) / 2;

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 7296
n = int(input())
s = input()
tw = s.count("W")
cw = 0
ans = min(tw, n-tw)
for i in range(n):
    if s[i] == "W":
        cw += 1
    ans = min(ans, cw + n-i-1 - (tw-cw) - min(cw, n-i-1 - (tw-cw)))
print(ans)

Measured memory_bytes: 67832
using System;
using System.Collections.Generic;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            //Grand Garden 茶色
            //https://atcoder.jp/contests/abc116/tasks/abc116_c

            int N = int.Parse(Console.ReadLine());
            string[] strArray = Console.ReadLine().Split(' ');
            int Count = 0;
            int[] Map = new int[N];
            while (Count < N)
            {
                Map[Count] = int.Parse(strArray[Count]);
                Count++;
            }

            Count = 0;
            //アルゴリズム
            int[] Current = new int[N];
            bool blnResult = true;
            bool blnStart = false;
            while (blnResult)
            {
                for (int i = 0; i < N; i++)
                {
                    if (Map[i] != Current[i])
                    {
                        Current[i]++;
                        if (blnStart == false)
                        {
                            Count++;
                            blnStart = true;
                        }
                    }
                    else
                    {
                        blnStart = false;
                    }
                }
                blnStart = false;
                blnResult = !Check(Map, Current);
            }

            Console.WriteLine(Count);
        }
        private static bool Check(int[] F, int[] C)
        {
            bool blnResult = true;
            for (int i = 0; i < F.Count(); i++)
            {
                if (F[i] != C[i])
                    blnResult = false;
            }
            return blnResult;
        }
    }

Measured memory_bytes: 13268
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	s    = bufio.NewScanner(os.Stdin)
	w    = bufio.NewWriter(os.Stdout)
	a, n = []int{}, 0
)

func main() {
	n = nextInt(s)
	a = atoi(s)
	_ = nextInt(s)
	m := atoi(s)

	for _, v := range m {
		i := 0
		if solve(i, v) {
			fmt.Fprintln(w, "yes")
			continue
		}
		fmt.Fprintln(w, "no")
	}
	w.Flush()
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	r, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return r
}

func atoi(s *bufio.Scanner) []int {
	s.Scan()
	a := strings.Fields(s.Text())
	i := []int{}

	for _, v := range a {
		j, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		i = append(i, j)
	}
	return i
}

func solve(i, m int) bool {
	if m == 0 {
		return true
	} else if i >= n {
		return false
	}
	return solve(i+1, m) || solve(i+1, m-a[i])
}



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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, d, e;
			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			d = a;
			e = b + c;
			if (b > d)
			{
				d = b;
				e = a + c;
			}

			if (c > d)
				e = a + b;

			Console.WriteLine(e);
		}
	}
}

Measured memory_bytes: 27316
import numpy as np

MOD = 10**9 + 7
n = int(input())
a = np.array(input().split(), np.int64)
max_num = np.max(a)
digit_num = len(format(max_num, 'b'))
ans = 0
for digit in range(digit_num):
    b = (a >> digit) & 1
    one = np.count_nonzero(b)
    zero = n - one
    ans += 2 ** digit * (one * zero)
    ans %= MOD

print(ans)

Measured memory_bytes: 62780
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int main()
{
	cin>>n;
	for(long long i=2;i<=sqrt(n);i++)
	{
		long long x=i;
		while(n%x==0)
		{
			n/=x;
			x*=i;
			ans++;
		}
		while(n%i==0)n/=i;
	}
	if(n!=1)ans++;
	cout<<ans;
}

Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String n = String.valueOf(sc.nextInt());
        
        int sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += Integer.parseInt(n.substring(i, i + 1));
        }
        boolean ans = false;
        if (Integer.parseInt(n) % sum == 0) {
            ans = true;
        }
        System.out.println(ans ? "Yes":"No");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(void){

  string S;  cin >> S;
  int ans = 1;

  for(int i = 1 ; i < S.size() ; i++)
    if(S[i] != S[i - 1])  ans += 1;

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const double pi = acos(-1);

struct Point
{
  double x, y;
  void print()
  {
    printf("(%.3lf, %.3lf)\n", x, y);
  }
  double dist(Point &other)
  {
    return sqrt((x - other.x)*(x - other.x) + (y - other.y)*(y - other.y));
  }
};

int main()
{
  int a, b, h, m;
  while (scanf("%d %d %d %d", &a, &b, &h, &m) != EOF)
  {
    double minuteAngle = (double)m / 60 * 2 * pi;
    double hourAngle = (double)h / 12 * 2 * pi + minuteAngle / 12;
    Point hour = {a * cos(hourAngle), a * sin(hourAngle)};
    DEBUG hour.print();
    Point minute = {b * cos(minuteAngle), b * sin(minuteAngle)};
    DEBUG minute.print();
    printf("%.15lf\n", hour.dist(minute));
  }
  return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int N,num,count=0;
	bool flag;
	
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>num;
		flag=true;
		if(num==2) count++;
		if(num%2==0) flag=false;
		for(int j=3;j<=sqrt(num);j+=2){
			if(num%j==0){
				flag=false;
				break;
			}
		}
		if(flag==true) count++; 
	}
	cout<<count<<endl;
	return 0;
}

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

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

	char ch;
	cin >> ch;
	cout << (char)(ch + 1) << endl;
	return 0;
}


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

int main(int argc, char const *argv[])
{
  int a, b;
  cin >> a >> b;
  cout << a/b << " " << a%b << " " << fixed << setprecision(10) << (double)a/b << endl;
  return 0;
}

Measured memory_bytes: 3280
// checklist
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	int x[n]; int sum=0;
	for(int i=0;i<n;i++){
		cin >> x[i];
		sum += x[i];
	}
	sum/=n; int sum2=sum+1;
	int pdt=0,pdt2=0;
	for(int i=0; i<n; i++){
		int dif = x[i]-sum;
		int dif2 = x[i]-sum2;
		pdt += dif*dif;
		pdt2 += dif2*dif2;
	}
	cout << min(pdt,pdt2) << endl;
}	


Measured memory_bytes: 256
s = input()
s.index

def check(s):
    try:
        res = s.index("C", 2, -1)
    except ValueError:
        return False
    if ((s[1:res]+s[res+1:]).islower()):
        return True


if (s[0] == "A" and check(s)):
    print("AC")
else:
    print("WA")

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <list>
#include <functional>
#include <algorithm>

using namespace std;

int cnt_i(int n, int s, bool ns[],int d,int sum,int m){
//    if(n>d+1) return 0;
    if(s<sum) return 0;
    if(n==d+1 && s == sum) return 1;
    if(n==d+1) return 0;
    int tmp(0);
    for(int i(m+1);i<=9;++i){
//	if(!ns[i]){
	    auto cpns=ns;
	    cpns[i]=1;
	    tmp += cnt_i(n,s,cpns,d+1,sum+i,i);
//	}
    }
    return tmp;
}
    
// int cnt_i2(int n, int s, bool ns[],int d,int sum,int m){
//     int tmp=0;
//     for(int i(m+1);i<=9;++i)
// 	tmp += cnt_i(n,s,ns,d+1,sum+i,m);

int cnt(int n, int s){
    bool ns[10] = {0,0,0,0,0,0,0,0,0,0};
    return cnt_i(n,s,ns,-1,0,-1);
}
    

int main(int, char**){
    int n,s;
    while(1){
	cin >> n >> s;
	if(n==0&&s==0) break;
	cout << cnt(n,s) << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    string S;
    cin>>S;
    int ans=0;
    if(S.size()==1){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;;i++){
        if(S.size()-1-i<i)break;
        if(S[i]!=S[S.size()-1-i])ans++;

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


Measured memory_bytes: 3644
def check_set(hand):
    set_list = []
    for i in range(9):
        if hand.count(i + 1) >= 3:
            set_list.append([i + 1, i + 1, i + 1])
        if i + 1 in hand and i + 2 in hand and i + 3 in hand:
            set_list.append([i + 1, i + 2, i + 3])
    return set_list

def check_winning(hand):
    if len(hand) == 2:
        if hand[0] == hand[1]:
            return True
        else:
            return False
    set_tmp_list = check_set(hand)
    if len(set_tmp_list) == 0:
        return False
    for set_tmp in set_tmp_list:
        hand_tmp = hand[:]
        for i in range(3):
            hand_tmp.remove(set_tmp[i])
        res = check_winning(hand_tmp)
        if res:
            break
        else:
            continue
    return res

while True:
    try:
        inp = list(map(int, list(input())))
        ans = []
        for i in range(9):
            if inp.count(i + 1) >= 4:
                continue
            inp_tmp = inp[:]
            inp_tmp.append(i + 1)
            if check_winning(inp_tmp):
                ans.append(i + 1)
        if len(ans) == 0:
            print(0)
        else:
            print(*ans)
    except:
        break




Measured memory_bytes: 5608
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)

Measured memory_bytes: 41948
import sys
n = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
#print(L)

dp = [[0 for _ in range(3)] for _ in range(n)]
dp[0] = L[0].copy()

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + L[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + L[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + L[i][2]

print(max(dp[-1]))

Measured memory_bytes: 47384
#define isFile 0
#include <iostream>
#include <math.h>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <cstdlib>
#include <fstream>
#include <stdio.h>
#include <utility>
#include <ctype.h>
#include <cassert>
#include <list>
#include <numeric>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef long long int lli;
 
// #define mp make_pair 
#define pb push_back
#define pf push_front
#define ed cout << endl
#define PI acos(-1)
#define NAME "choose"
// #define name "choose"
#define all(x) x.begin(),x.end()
#define F first 
#define S second
#define T third
#define mk make_pair
#define sz(x) int(x.size())
#define repi(a, b) for (int i = a; i < b; i ++)
#define repj(a, b) for (int j = a; j < b; j ++)
#define yes cout << "yes"
#define no cout << "no"
 
const ll MOD = 1e7 + 9;
const long double EPS = 3e-16;
const ll MAXN = 2e5 + 7;
const ll INF = 1e9;
 
void file(){
    freopen(NAME".in", "r", stdin);
    if (isFile) freopen(NAME".out", "w", stdout);
}


void solve(){
  int s, w;
  cin >> s >> w;
  if (w < s){
    cout << "safe";
    ed;
  }
  else{
    cout << "unsafe";ed;
  }
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  // file();
  int t = 1;
  // cin >> t;
  while(t--){
    solve();
  }

  return 0;
}
    


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///
vector<vi> v;
vs res;

void solve(int i, int d)
{
	REP(j, d) cout << '.';
	cout << res[i] << endl;
	REP(j, v[i].size()) solve(v[i][j], d + 1);
}

int main()
{
	int n; cin >> n;
	v.resize(n);
	res.resize(n);
	REP(i, n)
	{
		int k;
		cin >> k >> res[i];
		k--;
		if (k >= 0) v[k].push_back(i);
	}

	solve(0, 0);
	return 0;
}

Measured memory_bytes: 1440
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define print(a) cout << a << endl
#define V vector
typedef string str;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	str s;
	rep(i,3){
		str t;cin >> t;
		s+=t.at(0)-32;
	}
	print(s);
	return 0;
}

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

int main() {
  char a;
  cin >> a;
  if (a=='A'||a=='B'||a=='C'||a=='D'||a=='E'||a=='F'||a=='G'||a=='H'||a=='I'||a=='J'||a=='K'||a=='L'||a=='M'||a=='N'||a=='O'||a=='P'||a=='Q'||a=='R'||a=='S'||a=='T'||a=='U'||a=='V'||a=='W'||a=='X'||a=='Y'||a=='Z') cout << 'A' << endl;
  else cout << 'a' << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

int main() {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> X(N);
  REP(i,N){
  cin >> X[i].first;
  cin >> X[i].second;
  }
  sort(ALL(X));
  ll cnt=M;
  ll ans=0;
  while(cnt > 0){
    static int i =0;
    if(cnt > X[i].second){
      ans += X[i].first * X[i].second;
      cnt -= X[i].second;
    }else{
      ans += X[i].first * cnt;
      cnt=0;
    }
    ++i;
  }
  OUT(ans);
}	

Measured memory_bytes: 1792
k = int(input())

from collections import deque
d = deque()
for i in range(1,10):
    d.append(i)

count = 0
while True:
    count += 1
    if count == k:
        print(d.popleft())
        exit()
    t = d.popleft()
    r = t % 10
    if r != 0:
        d.append(10*t + r - 1)
    d.append(10*t + r)
    if r != 9:
        d.append(10*t + r + 1)

Measured memory_bytes: 74704
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int n,t,p,c=0;
  string st;
  cin>>n>>t;
  queue<pair<string,int> >a;
  while(n--){
    cin>>st>>p;
    a.push(make_pair(st,p));
  }
  while(!a.empty()){
    pair<string,int>b=a.front();
    a.pop();
    if(b.second<=t){
      c+=b.second;
      cout<<b.first<<' '<<c<<endl;
    }
    else{
      b.second-=t;
      c+=t;
      a.push(b);
    }
  }
}


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int a,b;
  cin >> a >> b;
  if ( a<0 && b > 0){
    cout << "Zero" << endl;
  }else if ( a>0){
    cout << "Positive" << endl;
  }else if ( b < 0){
    cout <<( (b-a)%2 == 1 ? "Positive" : "Negative" )<< endl;
  }
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
  
  char str[1300];
  int i,tmp;
 
  for(i=0;;i++){
    scanf("%c",&str[i]);
    if(str[i]== '\n'){
      tmp=i;
      break;
    }
    if('A' <= str[i] && str[i] <= 'Z'){
      str[i]=str[i]+32;
    }
    else if('a'<= str[i] && str[i] <= 'z'){
      str[i]=str[i]-32;
    }
  }
  for(i=0;i<tmp;i++){
    printf("%c",str[i]);
  }
  printf("\n");
  return 0;
}



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

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if(s=="abc") cout << "Yes" <<endl;
    else cout <<"No" <<endl;
    return 0;
}

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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359


/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n, ga,gb,sa,sb,ba,bb;
int DP[30000000];

int fun(int N, int T)
{

	if (N==0)return 0;
	if (DP[N]!=-1)return DP[N];

	if (!T)
	{
		int ret=N;
		if (N>=ga)ret=max(ret,(gb)+fun(N-ga,T));
		if (N>=sa)ret=max(ret,(sb)+fun(N-sa,T));
		if (N>=ba)ret=max(ret,(bb)+fun(N-ba,T));

		///cout<<ret<<"\n";
		return DP[N]=ret;
	}
	else
	{
		int ret=N;
		if (N>=gb)ret=max(ret,(ga)+fun(N-gb,T));
		if (N>=sb)ret=max(ret,(sa)+fun(N-sb,T));
		if (N>=bb)ret=max(ret,(ba)+fun(N-bb,T));
		return DP[N]=ret;

	}

}
void solve()
{
	cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;

	rep(i,0,n+1)DP[i]=-1;
	n=fun(n,0);

	rep(i,0,n+1)DP[i]=-1;
	n=fun(n,1);
	cout<<n<<"\n";


}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


Measured memory_bytes: 346752
N, K, *A = map(int, open(0).read().split())

l_pos = sorted(v for v in A if v > 0)
l_neg = sorted(-v for v in A if v < 0)

cnt_pos = len(l_pos)
cnt_neg = len(l_neg)

pair_pos = cnt_pos * (cnt_pos - 1) // 2 + cnt_neg * (cnt_neg - 1) // 2
pair_neg = cnt_pos * cnt_neg
pair_zro = N * (N - 1) // 2 - pair_pos - pair_neg


def solve_neg(n):
    ub = 10 ** 18 + 1
    lb = 0
    while ub - lb > 1:
        mid = (ub + lb) // 2
        
        # Count
        n_pos = len(l_pos)
        cnt = 0
        j = 0
        for v in reversed(l_neg):
            while j < n_pos and v * l_pos[j] < mid:
                j += 1
            cnt += n_pos - j

        if cnt < n:
            ub = mid
        else:
            lb = mid

    return -lb


def solve_pos(n):
    lb = 0
    ub = 10 ** 18 + 1
    while ub - lb > 1:
        cnt = 0
        mid = (ub + lb) // 2

        # Negative count
        n_neg = len(l_neg)
        j = 0
        for v in reversed(l_neg):
            if v ** 2 <= mid:
                cnt -= 1
            while j < n_neg and v * l_neg[j] < mid:
                j += 1
            cnt += j

        # Positive count
        n_pos = len(l_pos)
        j = 0
        for v in reversed(l_pos):
            if v ** 2 <= mid:
                cnt -= 1
            while j < n_pos and v * l_pos[j] < mid:
                j += 1
            cnt += j

        # Remove duplicated counts
        cnt //= 2

        if cnt < n:
            lb = mid
        else:
            ub = mid
            
    return lb


if K <= pair_neg:
    ans = solve_neg(K)
elif K <= pair_neg + pair_zro:
    ans = 0
else:
    ans = solve_pos(K - pair_neg - pair_zro)
print(ans)


Measured memory_bytes: 108236
# coding: utf-8
# Your code here!
def keisan(a,b):
    
    if a>2019:
        return True
    
    i=0
    while i<len(b):
        if b[i]==a :
            return True
        i+=1
    
    return False
    


koma_kazu=int(input()) #3

koma=input().rstrip().split()
komaI=[int(s) for s in koma]  #2,3,6

idou_kazu=int(input()) #2

idou=input().rstrip().split()
idouI=[int(s) for s in idou] #1,3


i=0
while i<idou_kazu:
    #if komaI[idouI[i]-1]+1 in komaI==False:
    if keisan(komaI[idouI[i]-1]+1,komaI)==False:
        komaI[idouI[i]-1]+=1
    i+=1

i=0
while i<koma_kazu:
    print(komaI[i])
    i+=1


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

const int N = (int) 1e2 + 5;

int n;
int h, w;
int a[N * N];
int ans[N][N];

int main() {
	
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> h >> w;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int x = 1, y = 1, dir = 1;
	for (int i = 1; i <= n; i++) {
		while (true) {
			ans[x][y] = i;
			a[i]--; 
			if (dir == 1) {
				y++;
				if (y == w + 1) {
					x++; y = w; dir = 0;
				}
			} else {
				y--;
				if (y == 0) {
					x++; y = 1; dir = 1;
				}
			}
			if (a[i] == 0) break;
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) cout << ans[i][j] << " ";
		cout << "\n";
	}
	return 0;
}

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

using namespace std;
int main(){
    int a[52],n,k,sn=0;
    cin >>n>>k;
    for(int i = 1 ; i < n+1 ; i++){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    for( int i = n ; i > n-k ; i--){
        sn+=a[i];
    }
    cout << sn <<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
High = list(map(int, input().split()))

inf = float("inf")
DP = [inf]*N
DP[0] = 0
DP[1] = abs(High[0]-High[1])

for i in range(N-1):
    for j in range(i + 1, min(N, i + K + 1)):
        DP[j] = min(DP[j], DP[i] + abs(High[i] - High[j]))
print(DP[N-1])

Measured memory_bytes: 55008
#include <stdio.h>
int n,hai[2000001];

void MaxH(int a){
  int x,y,L,change,left,right;
  left=2*a;
  right=2*a+1;

  if(n>=left && hai[left]>hai[a]){
    L=left;
  }
  else{L=a;}

  if(n>=right && hai[right]>hai[L]){
    L=right;
  }
  if(L!=a){
    change=hai[a];
    hai[a]=hai[L];
    hai[L]=change;
    MaxH(L);
  }
}

int main(){
  int i,j,k;

  scanf("%d",&n);

  for(i=1; i <=n; i++){
    scanf("%d",&hai[i]);
  }

  for(i=n/2; i>=1;i--){
    MaxH(i);
  }

  for(i=1; i <= n; i++){
   
     
        printf(" %d",hai[i]);
      
    
  }
  printf("\n");
    return 0;
}



Measured memory_bytes: 3676
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    vector<int> as(10);
    for (int i = 1; i <= 9; i++) {
        cin >> as[i];
    }

    vector<bool> found(10, false);

    int N;
    cin >> N;
    vector<int> bs(N);
    for (int i = 0; i < N; i++) {
        cin >> bs[i];
        for (int j = 1; j <= 9; j++) {
            if (as[j] == bs[i]) {
                found[j] = true;
            }
        }
    }

    if ((found[1] && found[2] && found[3])
            || (found[4] && found[5] && found[6])
            || (found[7] && found[8] && found[9])
            || (found[1] && found[4] && found[7])
            || (found[2] && found[5] && found[8])
            || (found[3] && found[6] && found[9])
            || (found[1] && found[5] && found[9])
            || (found[3] && found[5] && found[7])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
colors = [False]*8
high_rate_count = 0
for num in input().split():
    rate = int(int(num)/400)
    if rate > 7:
        high_rate_count += 1
    else:
        colors[rate] = True
count = 0
for color in colors:
    if color:
        count += 1
if count == 0:
    count = 1
    high_rate_count -= 1
max_count = count + high_rate_count
print(count, max_count)

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

int main()
{
  string s; cin >> s;
  int n = s.size();

  for (int i=n-2; i>0; i-=2) {
    if (strncmp(s.c_str(), s.c_str()+i/2, i/2) == 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    set<int> st;

    st.insert(a);
    st.insert(b);
    st.insert(c);

    cout << st.size() << endl;
    
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    res = 1
    plus = 0
    minus = 0
    for i in range(n-1):
        if a[i + 1] - a[i] > 0:
            plus += 1
        elif a[i + 1] - a[i] < 0:
            minus += 1
        if plus and minus:
            res += 1
            plus = 0
            minus = 0
    print(res)
if __name__ == '__main__':
    main()

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

long long mod = 1000000007LL;

long long fastPow(long long x, long long n){
    if(n == 0){
        return 1LL;
    }
    if(n % 2 == 0){
        return (fastPow((x * x) % mod, n / 2)) % mod;
    }
    if(n % 2 == 1){
        return (x * fastPow(x, n - 1)) % mod;
    }
    return -1LL;
}

int main()
{
    long long n, a, b;

    cin >> n >> a >> b;

    long long sum = 0;
    sum = fastPow(2, n) - 1;
    long long x = 1;
    long long y = 1;
    long long nCa = 1;
    long long nCb = 1;
    for (int i = 0; i < a; i++){
        x *= (n - i);
        x %= mod;
        y *= (i + 1);
        y %= mod;
    }
    nCa = (x * fastPow(y, mod - 2)) % mod;

    x = 1;
    y = 1;
    for (int i = 0; i < b; i++)
    {
        x *= (n - i);
        x %= mod;
        y *= (i + 1);
        y %= mod;
    }
    nCb = (x * fastPow(y, mod - 2)) % mod;

    sum -= nCa;
    sum = (sum + mod) % mod;
    sum -= nCb;
    sum = (sum + mod) % mod;

    cout << sum << endl;
}

Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define put putchar
using namespace std;
int h,w,a,b;
char c[1005][1005];
void write(){
	fo(i,1,h){
		fo(j,1,w)put(c[i][j]?'1':'0');
		put('\n');
	}
}
int main(){
	cin>>h>>w>>a>>b;
	if(a*2==w){
		if(b*2!=h&&b*2!=h-1){
			printf("-1");
			return 0;
		}
		fo(i,0,h-1){
			fo(j,0,w-1)put(i+j&1?'0':'1');
			put('\n');
		}
		return 0;
	}
	if(b*2==h){
		if(a*2!=w&&a*2!=w-1){
			printf("-1");
			return 0;
		}
		fo(i,0,h-1){
			fo(j,0,w-1)put(i+j&1?'0':'1');
			put('\n');
		}
		return 0;
	}
	fo(x,0,h)fo(y,0,w)
		if(a*x+(w-a)*(h-x)==b*y+(h-b)*(w-y)){
			fo(aa,0,a){
				int s=b*y-aa*x,bb=-1;
				if(h==x)bb=s==0;else{
					if(s%(h-x)==0)bb=s/(h-x);
				}
				if(bb>-1){
					int wz=1;
					if(y)
						fo(i,1,h){
							int nd=i<=x?aa:bb;
							fo(j,1,nd){
								c[i][wz]='1';
								++wz==y+1?wz=1:0;
							}
						}
					if(w-y){
						wz=y+1;
						fo(i,1,h){
							int nd=i<=x?a-aa:w-a-bb;
							fo(j,1,nd){
								c[i][wz]='1';
								++wz==w+1?wz=y+1:0;
							}
						}
					}
					write();
					return 0;
				}
			}
		}
	printf("-1");
}

Measured memory_bytes: 2176
while True:
    a, b = input().split()
    if b == 'X':
        break

    if '_' in a:
        ans = a.split('_')
    else:
        ans = []
        j = 0
        for i in range(1, len(a)):
            if a[i].isupper():
                ans.append(a[j:i])
                j = i
        ans.append(a[j:])
        
    if b == 'D':
        ans = '_'.join(map(str.lower, ans))
    else:
        ans = ''.join(map(str.capitalize, ans))
        
        if b == 'L':
            ans = ans[0].lower() + ans[1:]

    print(ans)



Measured memory_bytes: 5564
#include<cstdio>
int main(){
	long long del=0x3f3f3f3f,sum=0;
	int n;
	bool f=false;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		long long a,b;
		scanf("%lld%lld",&a,&b);
		if(a-b)f=true;
		sum+=a;
		if(b<a)
			del=del<b?del:b;
	}
	if(!f)	printf("0\n");
	else printf("%lld\n",sum-del);
}


Measured memory_bytes: 128
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
r,g,b,n=IL()
L=[r,g,b]
L.sort()
s,m,l=L
ans=0
for i in range(n//l+1):
    for j in range(n//m+1):
        if n-i*l-j*m<0:
            break
        elif (n-i*l-j*m)%s==0:
            ans+=1
            
print(ans)

Measured memory_bytes: 40556
#include <iostream>

using namespace std;

int main()
{
	int n;
	double x[4], y[4], a, b;
	
	cin >> n;
	while(n--){
		for(int i = 0; i < 4; i++){
			cin >> x[i] >> y[i];
		}
		
		if(x[0]-x[1] == 0){
			if(x[2]-x[3] == 0){
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		} else {
			a = (y[0]-y[1])/(x[0]-x[1]);
			b = (y[2]-y[3])/(x[2]-x[3]);
			if(a == b){
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<vector<ll>> graph(n);
    vector<ll> in(n);
    for(int i = 0; i < m; i++) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
        in[a]++;in[b]++;
    }
    bool ok = true;
    vector<ll> fc;
    ll oc = 0;
    rep(i,0,n){
        ok &= (~in[i] & 1);
        if(in[i] == 4)fc.emplace_back(i);
        if(in[i] == 6)oc++;
    }

    if(!ok){
        YES(false);
        return 0;
    }
    
    if(oc || fc.size() >= 3){
        YES(true);
        return 0;
    }

    if(fc.size() <= 1){
        YES(false);
        return 0;
    }

    ll st = fc[0], ed = fc[1];
    assert(fc.size() == 2);
    vector<ll> used(n);
    auto dfs = [&](auto self, ll now, ll pre = -1)->void{
        if(pre != -1)used[now] = 1;
        for(auto &to : graph[now]){
            if(to == pre)continue;
            if(to == ed)continue;
            if(used[to])continue;
            self(self, to, now);
        }
    };

    dfs(dfs, st);
    debug(used, st, ed);
    if(used[st]){
        YES(true);
    }
    else{
        YES(false);
    }
}

Measured memory_bytes: 14240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn= new Scanner(System.in);
		int n= scn.nextInt();
		 double val = n*1.0/3;
		double val1 = (val*val*val);
		System.out.println(val1);
		

	}

}

Measured memory_bytes: 20692
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy
#import heapq
#import math
#import string

setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
h=[int(i) for i in input().split()]
ans=0
for i in h:
    if i>=k:
        ans+=1
print(ans)

Measured memory_bytes: 11896
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int k, t;
	cin >> k >> t;
	vector<int> a(t);
	REP(i, t) {
		cin >> a[i];
	}
	int m = *max_element(all(a));
	if (m * 2 > k) {
		put( m * 2 - k - 1);
	}
	else {
		put(0);
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#define lli long long int
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  long n;
  cin >> n;
  long a[100000];
  rep(i, n){
    cin >> a[i];
  }
  long ans = 0;
  long j = 0;
  long b = 100000;
  rep(i, n){
    if(a[i] < 0){
     j++;
    }
    if(b > abs(a[i])){
      b = abs(a[i]);
    }
  }
  if(j % 2 == 0){
    rep(i, n){
      ans += abs(a[i]);
    }
  }
  else{
    rep(i, n){
      ans += abs(a[i]);
    }
    ans = ans - 2 * b;
  }
  cout << ans;
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll N; cin >> N;
  string S; cin >> S;
  int b = 0; int ans = 0; bool flag = false;
  for(int i = N - 1; i >= 0; --i) {
    if(b == i) {
      flag = true;
      break;
    }
    if(S[i] == 'R') {
      while(true) {
        // bがiに衝突したら終了
        if(b == i) {
          flag = true;
          break;
        }
        // Wが見つかったら...
        if(S[b] == 'W') {
          ans++;
          // RとWを交換する
          swap(S[i], S[b]);
          b++;
          if(b == i) {
            flag = true;
            break;
          }
          break;
        }
        b++;
      }
    }
    if(flag == true) break;
  }
  cout << ans << endl;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, d;
  cin >> n >> d;
  int x[n][d];
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < d; ++j)
      cin >> x[i][j];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i + 1; j < n; ++j)
    {
      int sum = 0;
      for (int k = 0; k < d; ++k)
      {
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      for (int t = 1; t <= 1000; ++t)
      {
        if ((t * t) == sum)
        {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int N;
string S;
int main(void) {
	cin >> N;
	cin >> S;

	int ans = 0;
	S += "#";

	for (int i = 1; i <= N; i++) {
		if (S[i] != S[i - 1]) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int N, K, S;
  cin >> N >> K >> S;
  if(S != (int)INF){
    REP(i, K){
      cout << S << " ";
    }
    REP(i, N-K){
      cout << 1000000000 << " ";
    }
  }
  else{
    REP(i, K){
      cout << S << " ";
    }
    REP(i, N-K){
      cout << 1 << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1280