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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  int sum=0;
  for(int i=0; i<N; i++){
    cin >> L.at(i);
    sum+= L.at(i);
  }
  sort(L.begin(), L.end());
  if((sum-L.at(N-1))>L.at(N-1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    string out = "Yes";
    ll H[N];
    rep(i,N) cin >> H[i];
    rep(i,N-2){
        if(H[N-1-i]+1<H[N-2-i]){
            out = "No";
            break;
        }else if(H[N-1-i]+1 == H[N-2-i]){
            H[N-2-i]--;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1024
//
// Created by 李青坪 on 2018/11/10.
//

#include <cstdio>
#include <vector>
#include <algorithm>
#define MAXN 10000
#define NIL -1
using namespace std;

int n, q;

class DisjointSet{
private:
    vector<int> s;
    int p[MAXN];
    int height[MAXN];
public:
    DisjointSet(){
        fill(p, p+n, NIL);
        fill(height, height+n, NIL);
    }
    void makeSet(int x){
        s.push_back(x);
        p[x] = x;
        height[x] = 0;
    }
    int findSet(int x){
        if (p[x] != x){
            int t = findSet(p[x]);
            p[x] = t;
            return t;
        }
        else{
            return x;
        }
    }
    void unite(int x, int y){
        int r_x = findSet(x);
        int r_y = findSet(y);
        if (height[r_x] < height[r_y]){
            p[r_x] = r_y;
        }
        else{
            p[r_y] = r_x;
            if (height[r_x] == height[r_y]){
                ++height[r_x];
            }
        }
    }
    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }
};

int main(){
    scanf("%d %d", &n, &q);
    DisjointSet set;
    for (int j = 0; j < n; ++j) {
        set.makeSet(j);
    }
    for (int i = 0; i < q; ++i) {
        int com, x, y;
        scanf("%d %d %d", &com, &x, &y);
        if (com){
            printf("%d\n", set.same(x, y));
        }
        else{
            set.unite(x, y);
        }
    }
}
/*
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0
 */


Measured memory_bytes: 2920
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
#define NOW         chrono::system_clock::now()
#define ELP(s,e)    chrono::duration_cast<chrono::milliseconds>(e-s).count()
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll x = in();
	cout << (x == 7 || x == 5 || x == 3 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import sys
N, Y = map(int, input().split())
for i in range(Y//10000 + 1):
    for j in range((Y-i*10000)//5000 + 1):
        if ((Y-i*10000-j*5000)//1000) == N-i-j:
            print(i, j, N-i-j)
            sys.exit()
print(-1,-1,-1)


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

typedef long long ll;
ll g(ll p) {return p > 0 ? p : -p;}
int main()
{
	ll x, y;
	cin >> x >> y;
	cout << (g(x - y) <= 1 ? "Brown" : "Alice");
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,end = 0;
    String ans;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
      String line = reader.readLine();
      ans = line;
      
      while (true) {
        line = reader.readLine();
        for(String splitted: line.split(" ")){
           if (ans.equalsIgnoreCase(splitted)) a++;
           if (splitted.equals("END_OF_TEXT")) end = 1;
        }
        if(end == 1) break;
      }
      
		}catch(Exception e){
    }
  System.out.println(a);

  }
}


Measured memory_bytes: 24496
N = int(input())

bitts = ''
ans = ''

dic = 'abcdefghijklmnopqrstuvwxyz'

while (N > 0):
    N -= 1
    
    b = N // 26
    mod = N - 26 * b
    bitts += str(mod)
    
    ans += dic[mod]
    
    N = N // 26
    

print(ans[::-1])


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

string S;
int n;
lint ans = 0;

void dfs(int i, lint cur) {
	if (i == n) { ans += cur; return; }
	for_(j,i,n) {
		string sub = S.substr(i, j - i + 1);
		stringstream ss(sub);
		lint x; ss >> x;
		dfs(j + 1, cur + x);
	}
}

int main() {
	cin >> S;
	n = S.size();
	dfs(0, 0);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	ll A, B, K;
	cin >> A >> B >> K;

	if(K<=A){
		cout << A-K << " " << B << endl;
	} else {
		cout << 0 << " " << max(0ll, A+B-K) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())
change = S[K-1]
S.pop(K-1)
change = change.lower()
if(K == N):
    S.append(change)
else:
    S.insert(K-1,change)
Snew = "".join(S)
print(Snew)

Measured memory_bytes: 3060
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
//bool cmp(int x,int y)
//{
//	return x>y;
//}
//int a[1005];
//int flag1=0;
int main()
{
  int n;
cin>>n;
ll sum=0;
for(int i=1;i<=n;i++)
{
	if(i%3==0||i%5==0)
	continue;
	else
	
	sum+=i;
}
   printf("%lld\n",sum);
   return 0;
}

Measured memory_bytes: 3704
#include <iostream>
using namespace std;
 
int main()
{
	int a,b;
	cin >> a >> b;
  
	int seki;
	seki = a * b;
 
	if (seki % 2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;
}

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

using namespace std;

const int oo = 1e9;
const int N = 5e5 + 100;
const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

typedef pair<int,int> i2;
typedef pair<int,i2> i3;

int n;
int a[3][N],kt[3][N];
void nhap()
{

}
void solve() {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int Res = 0;
    int d = 0;
    for (int i = 1; i <= min(X,Y); i++) {
        if (C * i * 2 > A * i + B * i) {
            break;
        }
        d = i;
    }
    Res = d * C * 2;
    X -= d;
    Y -= d;
    if (C * 2 <= A) {
        Res += X * C * 2;
        Y -= X;
        X = 0;
    }
    if (C * 2 <= B && Y > 0) {
        Res += Y * C * 2;
        X -= Y;
        Y = 0;
    }
    if (X > 0) {
        Res += X * A;
    }
    if (Y > 0) {
        Res += Y * B;
    }
    cout << Res;
}
int main()
{
    nhap();
    solve();
}


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

int main( )
{
    int n, m, x, y;
    int i, j, k;
    int d;
    int mx = -1000, mn = 1000;
    cin >> n >> m >> x >> y;
    for (i = 1; i <= n; i++)
    {
        cin >> d;
        mx = max(mx, d);
    }
    for (i = 1; i <= m; i++)
    {
        cin >> d;
        mn = min(mn, d);
    }
    for (x++ ; x <= y; x++)
    {
        if (mx < x && mn >= x)
        {
            cout << "No War\n";
            return 0;
        }
    }
    cout << "War\n";
    return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    if(S[2]==S[3] and S[4]==S[5]):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

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

using namespace std;

int main(void) {
    long long N;
    cin >> N;
    vector <long long> c(5);
    for (int i = 0; i < 5; i++) {
        cin >> c[i];
    }

    long long min_c = 10000000000000000;
    int argmin_c = -1;
    for (int i = 0; i < 5; i++) {
        if (c[i] < min_c) {
            min_c = c[i];
            argmin_c = i;
        }
    }

    long long ans = 5 + N / min_c;
    if (N % min_c == 0) {
        ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    import sys
    import math

    ALPHABET = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
                "V", "W", "X", "Y", "Z"]
    result = []

    def alphabet_decimal(v):
        quotient = math.floor(v / len(ALPHABET))
        surplus = v % len(ALPHABET)
        quotient -= 1 if surplus == 0 else 0
        surplus = len(ALPHABET) if surplus == 0 else surplus
        result.append(surplus)
        if len(ALPHABET) < quotient:
            alphabet_decimal(quotient)
        elif len(ALPHABET) < v:
            result.append(quotient)
        return "".join([ALPHABET[i - 1] for i in reversed(result)])

    res = alphabet_decimal(n)

    print(res.lower())

resolve()

Measured memory_bytes: 62352
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
    }

    let sum: usize = a.iter().sum();
    let b = a.iter().filter(|&v| v * 4 * m >= sum);
    if b.count() >= m {
        println!("Yes");
    } else {
        println!("No");
    };
}

Measured memory_bytes: 4352
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                while(n != 0){ 
                        int s = sc.nextInt();
                        System.out.println(combination(s, 0, n));
                        n = sc.nextInt();
                }   
                sc.close();
        }   
        static int combination(int s, int floor, int n){
                if(n == 1){ 
                        return s <= 9 && floor <= s ? 1: 0;
                }else{
                        int sum = 0;
                        for(int i = floor; i <= 9 && i < s-i; i++){
                                sum += combination(s-i, i+1, n-1);
                        }   
                        return sum;
                }   
        }   
}

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

struct activity{
  int A, B, C ;
};

int solve(vector<activity>arr, int n){

  int dp[n][3] ;

  dp[0][0] = arr[0].A ;
  dp[0][1] = arr[0].B ;
  dp[0][2] = arr[0].C ;

  for(int i = 1; i<n; i++ ){
    dp[i][0] = arr[i].A + max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = arr[i].B + max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = arr[i].C + max(dp[i-1][0],dp[i-1][1]);
  }

  return (max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]))) ;
}

int main() {

int n ;
cin>>n;

vector<activity> arr(n) ;

for(int i = 0; i<n; i++){
  cin>>arr[i].A ;
  cin>>arr[i].B ;
  cin>>arr[i].C ;
}

cout<<solve(arr,n) ;


return 0;
}

Measured memory_bytes: 3712
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] n=new int[5];
		for(int i=0;i<5;i++) n[i]=sc.nextInt();
		Arrays.sort(n);
		System.out.println(n[4]+" "+n[3]+" "+n[2]+" "+n[1]+" "+n[0]);
		sc.close();
	}
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
 
//#define int long long
const int MOD = 1e9 + 7;
using ll = long long;
using intpair = pair<int, int>;
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    string s; cin >> s;
    reverse(ALL(s));
    int n = s[0] - '0';
    
    if(n == 3){
        cout << "bon" << endl;
    }else if(n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

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

int main() {
    int min = 10;
    int t = 0;
    int nextOrderTime = 0;

    for (int i = 0; i < 5; i++) {
      cin >> t;
      if (min > t % 10 && t % 10) {
        min = t % 10;
      }
      if (t % 10 == 0) {
        nextOrderTime += t;
      } else {
        nextOrderTime += ((t / 10) + 1) * 10;
      }
    }
    cout << nextOrderTime - 10 + min << endl;

    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int main(void){
    int a,b,i;
    scanf("%d%d",&a,&b);
    char c[a+b+2];
    scanf("%s",c);
    if(c[a]!='-'){
        printf("No");
        return 0;
    }
    for(i=0;c[i]!='\0';i++){
        if(i!=a && c[i]=='-'){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}



Measured memory_bytes: 128
N, *L = map(int, open(0).read().split())
cost = []
for m in zip(*[iter(L)]*N):
  cost.append(m)
ans = 0
for i in range(N):
  for j in range(i):
    for k in range(N):
      if k==i or k==j:
        continue
      if cost[i][j]>cost[i][k]+cost[k][j]:
        print(-1)
        import sys
        sys.exit()
      if cost[i][j]==cost[i][k]+cost[k][j]:
        break
    else:
      ans += cost[i][j]
print(ans)


Measured memory_bytes: 66828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 2e5+5;

int n, m;
char s[22][22];

int fnc(int x, int y)
{
   int ans = 0;
   for(int i=0; i<n; i++) {
      if(x & (1<<i)) continue;
      for(int j=0; j<m; j++) {
         if(y & (1<<j)) continue;
         if(s[i][j] == '#') ans++;
      }
   }
   return ans;
}

int main()
{
   int k;
   cin >> n >> m >> k;
   for(int i=0; i<n; i++) scanf("%s", s[i]);

   int ans = 0;
   for(int i=0; i<(1<<n); i++) {
      for(int j=0; j<(1<<m); j++) {
         if(fnc(i, j) == k) ans++;
      }
   }

   cout << ans << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define P 998244353
#define MAX_N 200000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
char s[MAX_N+5];
int n, m, a[MAX_N+5];
int f[2][3][3][2];
bool AllSame() {
	for (int i = 1; i < n; i++)
		if (a[i] ^ a[i+1]) return false;
	return true;
}
bool AllDiff() {
	for (int i = 1; i < n; i++)
		if (a[i] == a[i+1]) return false;
	return true;
}
void Brute() {
	if (n == 2) {puts(a[1] == a[2] ? "1" : "2"); return;}
	if ((a[1]^a[2]) && (a[2]^a[3]) && (a[1]^a[3])) puts("3");
	else puts(AllSame() ? "1" : (a[1] == a[3] ? "7" : "6"));
}
void DP() {
	if (AllSame()) {puts("1"); return;}
	for (int i = 0; i < 3; i++) f[1][i][i][0] = 1;
	for (int i = 1; i <= n; i++) (m += a[i]) %= 3;
	for (int l = 1, c = 1; l <= n; l++, c ^= 1) {
		memset(f[c^1], 0, sizeof f[c^1]);
		for (int s = 0; s < 3; s++)
			for (int i = 0; i < 3; i++)
				for (int j = 0; j < 3; j++)
					(f[c^1][(s+j)%3][j][1] += f[c][s][i][1]) %= P, 
					(f[c^1][(s+j)%3][j][i==j] += f[c][s][i][0]) %= P;
	}
	int ans = AllDiff();
	for (int i = 0; i < 3; i++)
		(ans += f[n&1][m][i][1]) %= P;
	printf("%d\n", ans);
}
int main() {
	scanf("%s", s+1), n = (int)strlen(s+1);
	for (int i = 1; i <= n; i++) a[i] = s[i]-'a';
	return (n <= 3 ? Brute() : DP()), 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

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

int main() {
  int N, A, i;
  cin >> N ;

  char S[N];

  for(i=0;i<N;i++){
    cin >>S[i];
  }
 bool p=0,w=0,g=0,y=0;
  for(i=0;i<N;i++){
    if(S[i]=='P'){p=1;}
    else if(S[i]=='W'){w=1;}
    else if(S[i]=='G'){g=1;}
    else if(S[i]=='Y'){y=1;}
  }
  int ret;
  ret=p+w+g+y;
  if (ret==3)cout<<"Three"<<endl;
  else if(ret==4)cout<<"Four"<<endl;
}


Measured memory_bytes: 256
require "set"
n,m = gets.chomp.split(" ").map(&:to_i)
ab_arr = m.times.map{gets.chomp.split(" ").map(&:to_i)}

hash = {}
edge = []
# 無向グラフを作成
ab_arr.each do |(a, b)|
  hash[a] ||= []
  hash[a] << b
  hash[b] ||= []
  hash[b] << a
  # 辺は小さい順に並べたほうが都合が良い(a == bはあり得ないので考慮しなくてOK)
  edge << [a, b] if a < b
  edge << [b, a] if b < a
end

count = 0
# 各辺を取り除いたときに, 全頂点がたどれるかを確認
edge.each do |(e_a, e_b)|
  bfs = [1]
  node_set = Set.new([1])
  edge_set = Set.new
  while bfs.length > 0 do
    a = bfs.shift
    hash[a].each do |b|
      # 小さい順に並べたほうが都合が良い
      in_a, in_b = a, b if a < b
      in_a, in_b = b, a if b < a
      # 通れない辺
      next if e_a == in_a && e_b == in_b
      # すでに通った辺
      next if edge_set.include?([in_a, in_b])
      bfs << b
      node_set << b
      edge_set << [in_a, in_b]
    end
  end
  # 全頂点通れないなら橋としてカウント
  count += 1 if node_set.length != n
end

puts count


Measured memory_bytes: 14448
n,m = map(int, input().split())
arr = [[0]*n for _ in range(n)]
for _ in range(m):
  a,b = map(int, input().split())
  arr[a-1][b-1] = 1
  arr[b-1][a-1] = 1
d = [0]*n
d[0] = 1
cnt = 0
def dfs(x):
  global cnt
  if all(d):
    cnt += 1
  for i in range(1,n+1):
    if arr[x-1][i-1] and d[i-1] == 0:
      d[i-1] = 1
      dfs(i)
      d[i-1] = 0
dfs(1)
print(cnt)

Measured memory_bytes: 3064
# ==================================================== #
# -*- coding: utf-8 -*
n, m = map(int, input().split())
arr = [0] * 114514

for i in range(m):
    a, b = map(int, input().split())
    arr[a-1] += 1
    arr[b-1] += 1

for i in range(n):
    print(arr[i])

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[] = {}, b[] = {}, c[] = {};
        vstr v;
        ll vercnt = 0, horcnt = 0;
        rep(i, n){
            cin >> s;
            each(c, s){
                if(c == '#'){
                    cnt++;
                }
            }
        }
        print(cnt == n + m - 1 ? "Possible" : "Impossible");
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

string tree(const string &s, int &pos){
	string chl, chr;
	++pos;
	if (s[pos] == '(') chl = tree(s, pos);
	++pos;
	if (s[pos] == '(') chr = tree(s, pos);
	++pos;
	return "(" + chl + "," + chr + ")";
}

char c;
string a, b;
int p1, p2;

string AND(){
	++p1, ++p2;

	string chl, chr;
	if (a[p1] == '(' && b[p2] == '('){
		chl = AND();
	}
	else if (a[p1] == '('){
		tree(a, p1);
	}
	else if (b[p2] == '('){
		tree(b, p2);
	}

	++p1, ++p2;

	if (a[p1] == '(' && b[p2] == '('){
		chr = AND();
	}
	else if (a[p1] == '('){
		tree(a, p1);
	}
	else if (b[p2] == '('){
		tree(b, p2);
	}

	++p1, ++p2;

	return "(" + chl + "," + chr + ")";
}

string OR(){
	++p1, ++p2;

	string chl, chr;
	if (a[p1] == '(' && b[p2] == '('){
		chl = OR();
	}
	else if (a[p1] == '('){
		chl = tree(a, p1);
	}
	else if (b[p2] == '('){
		chl = tree(b, p2);
	}

	++p1, ++p2;

	if (a[p1] == '(' && b[p2] == '('){
		chr = OR();
	}
	else if (a[p1] == '('){
		chr = tree(a, p1);
	}
	else if (b[p2] == '('){
		chr = tree(b, p2);
	}

	++p1, ++p2;

	return "(" + chl + "," + chr + ")";
}

int main(){
	while (cin >> c >> a >> b){
		p1 = p2 = 0;

		if (c == 'i') cout << AND() << endl;
		else cout << OR() << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
using namespace std;
#define MAX 1000

int main(){
  int n,a[100];
  int alice=0,bob=0;
  cin>>n;
  for(int i=1; i<=n; i++) cin>>a[i];
  sort(a, a+n);
  for(int i=1; i<=n-1; i++){
    for(int j=i+1; j<=n; j++){
      if(a[i]<a[j]){
        int str;
        str=a[i];
        a[i]=a[j];
        a[j]=str;
      }
    }
  }
  
  for(int i=1; i<=n; i++){
    if(i%2==1) alice+=a[i];
    else bob+=a[i];
  }
  
  cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    vvl g(n);
    vl count(n,-1),link(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    ll p=0;
    vl dist(n,-1);
    queue<ll> que;
    set<ll> s;
    s.insert(0);
    dist[0]=0;
    que.push(0);
    link[0]=p;
    ll a=0;
    while(!que.empty()){
        ll v=que.front();
        que.pop();
        for(ll nv:g[v]){
            if(dist[nv]!=-1)continue;
            dist[nv]=0;
            link[nv]=p;
            s.insert(nv);
            que.push(nv);
        }
        if(que.empty()){
            p++;
            for(auto x:s)count[x]=s.size();
            s.clear();
            while(dist[a]==0&&a<n)a++;
            if(a==n)break;
            que.push(a);
            s.insert(a);
            dist[a]=0;
            link[a]=p;
        }
    }
    rep(i,k){
        ll a,b;cin >> a >> b;
        a--;b--;
        if(link[a]==link[b]){
            count[a]--; count[b]--;
        }
    }
    rep(i,n){
        cout << count[i]-1-g[i].size() <<" ";
    }
}

Measured memory_bytes: 14964
n = int(input())
nums = list(map(int,input().split()))
ans = 0
B = []

for i in range(n):
    a = nums[i] - (i + 1)
    B.append(a)

B.sort()
b = B[n // 2]

for j in range(n):
    ans += abs(nums[j] - (j + 1 + b))

print(ans)

Measured memory_bytes: 26184
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll n,k;
  cin>>n>>k;
  vl x(n);
  vl y(n);
  vector<char> c(n);
  vll result(k*2,vl(k*2,0));//左上、の集合を記録
  rep(i,n){
    cin>>x[i]>>y[i]>>c[i];
  }
  rep(i,n){
    x[i]%=k*2;
    y[i]%=k*2;
    if(c[i]=='B'){
      x[i]+=k;
      x[i]%=2*k;
      //cout<<"e";
    }
    //cout<<"l";
    /*rep(ii,k){
      rep(j,k){
        int i2=k/2-ii+2*k;
        int j2=k/2-j+2*k;
        result[(i2+y[i])%(2*k)][(j2+x[i])%(2*k)]++;
      }
    }*/
    result[y[i]][x[i]]++;
  }
  vll result2(k*3,vl(k*3,0));
  rep(i,k*2){
    rep(j,k*2){
      result2[i][j]+=result[i][j];
      result2[(i+k)][(j+k)]+=result[i][j];
      result2[i][(j+k)]-=result[i][j];
      result2[(i+k)][j]-=result[i][j];
    }
  }
  //二次累積和
  rep(i,3*k){
    rep(j,3*k-1){
      result2[i][(j+1)]+=result2[i][(j)];
    }
  }
  rep(j,3*k){
    rep(i,3*k-1){
      result2[(i+1)][j]+=result2[(i)][j];
    }
  }
  //同じ部分をまとめる
  rep(i,k){
    rep(j,k){
      ll i2=i+k;
      ll j2=j+k;
      result2[i][j]+=result2[i2][j2];
      i2=i;
      j2=j+2*k;
      result2[i][j]+=result2[i2][j2];
      i2=i+2*k;
      j2=j;
      result2[i][j]+=result2[i2][j2];
      i2=i+2*k;
      j2=j+2*k;
      result2[i][j]+=result2[i2][j2];
    }
  }
  rep(i,k){
    rep(j,k){
      ll i2=i+k;
      ll j2=j;
      result2[i][j+k]+=result2[i2][j2];
      i2=i+2*k;
      j2=j+k;
      result2[i][j+k]+=result2[i2][j2];
      i2=i+k;
      j2=j+2*k;
      result2[i][j+k]+=result2[i2][j2];
    }
  }
  ll ans=0;
  rep(i,k){
    rep(j,k*2){
      ans=max(ans,result2[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 103680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#define llong long long
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e18 + 7;
ll tc, n, m, q, a, b, c, d, i, j, k, ans;
ll dist[25][25];
string s[25];
vector < ll > vec;

int main()
{
    faster_io;
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        cin >> s[i], s[i] = "#" + s[i];
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= m; j++)
        {
            if(s[i][j] == '#')
                continue;
            queue<pll> q;
            mem(dist, -1);
            q.push({i, j});
            dist[i][j] = 0;
            //cout << i <<  ' ' << j << endl << endl;
            while(!q.empty())
            {
                pll p = q.front();
                //cout << p.F << ' ' << p.S << ' ' << dist[p.F][p.S] << endl;
                q.pop();
                if(s[p.F + 1][p.S] == '.' && dist[p.F + 1][p.S] == -1)
                    q.push({p.F + 1, p.S}), dist[p.F + 1][p.S] = dist[p.F][p.S] + 1;
                if(s[p.F - 1][p.S] == '.' && dist[p.F - 1][p.S] == -1)
                    q.push({p.F - 1, p.S}), dist[p.F - 1][p.S] = dist[p.F][p.S] + 1;
                if(s[p.F][p.S + 1] == '.' && dist[p.F][p.S + 1] == -1)
                    q.push({p.F, p.S + 1}), dist[p.F][p.S + 1] = dist[p.F][p.S] + 1;
                if(s[p.F][p.S - 1] == '.' && dist[p.F][p.S - 1] == -1)
                    q.push({p.F, p.S - 1}), dist[p.F][p.S - 1] = dist[p.F][p.S] + 1;
            }
            for(a = 1; a <= n; a++)
                for(b = 1; b <= m; b++)
                    ans = max(ans, dist[a][b]);
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, n = 0;
  cin >> A >> B;

  for (int i = A; i < (B+1); i++){
    int X = i, j = 0;
    while (X >= 1) {
      X /= 10;
      j++;
    }

    bool flag = true;
    for (int k = 0; k < (j/2); k++) {
      int a = 1, b = 1, x, y;
      for (int l = 0; l < k; l++)
        a *= 10;
      x = (i / a) % 10;
      for (int l = 0; l < (j-k-1); l++)
        b *= 10;
      y = (i / b) % 10;
      
      if (x == y)
        continue;
      else {
        flag = false;
        break;
      }
    }

    if (flag)
      n++;
  }

  cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <iomanip>
#include <map>


#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i <= num / 2; i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int Q;
    cin >> Q;

    int m[100001] = {};
    m[0] = 0;
    m[1] = 0;
    m[2] = 0;

    for(int i = 3; i < 100001; i += 2)
    {
        m[i] = m[i-1];
        if(isPrime(i) && isPrime((i+1)/2))++m[i];

        //偶数位置
        m[i+1] = m[i];
    }

    REP(i,Q)
    {
        int l,r;
        cin >> l >> r;

        cout << m[r] - m[l-1] << endl;
    }

    return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    if (h > w) swap(h, w);
    int sum = 0, ans = 0;
    for (int i = 0; i < h; ++i) {
        ++ans;
        sum += w;
        if (sum >= n) break;
    }
    cout << ans << endl;
    return 0;
}



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


int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  
  vector<int> cnt(N-1);
  const int shortcut = Y - X - 1;
  int temp;
  for (auto j = N; j > 0; --j) {
    for (auto i = 1; i < j; ++i){
      //cout << j << ',' << i << endl;
      // must use shortcut
      if (i <= X && j >= Y) {
        ++cnt[(j - shortcut - i) - 1];
        //cout << j - shortcut - i << endl;
      }
      // must think whether shortcut is used
      else if (i > X && j < Y) {
        temp = min(j-i, Y-j+1+i-X);
        ++cnt[temp - 1];
        //cout << j - i << endl;
      }
      else if (i <= X && j < Y) {
        temp = min(j-i, Y-shortcut-i+Y-j);
        ++cnt[temp - 1];
        //cout << temp << endl;
      }
      else {
        temp = min(j-i, j-shortcut-X+i-X);
        ++cnt[temp - 1];
        //cout << temp << endl;
      }
    }
  }
  
  for(auto xi : cnt) {
    cout << xi << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
#define mp make_pair
#define Pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define maxn 200100
#define INF 0x7fffffff
using namespace std;
int n,m,s,t;
LL d[maxn];
LL cnt[maxn];
bool vis[maxn];
vector<int> G[maxn];
void spfa(){
	for(int i=1;i<=n;i++){
		d[i]=INF;
		vis[i]=false;
	}
	queue<int> Q;
	vis[1]=true;
	d[1]=0;
	Q.push(1);
	int p,now,w;
	while(!Q.empty()){
		p=Q.front();
		Q.pop();
		vis[p]=false;
		for(int i=0;i<G[p].size();i++){
			now=G[p][i];
			if(d[now]>d[p]+1){
				d[now]=d[p]+1;
				if(!vis[now]){
					Q.push(now);
					vis[now]=true;
				}
			}
		}
	}
}
int main(){
	cin>>n>>m;
	int u,v,w;
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
	}
	spfa();
	if(d[n]!=2) cout<<"IMPOSSIBLE";
	else cout<<"POSSIBLE";
	return 0;
}

Measured memory_bytes: 15344
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {
  
  string S, T;
  cin >> S >> T;

  int ans = INF;
  rep(i,S.length()-T.length()+1) {
    int count = 0;
    rep(j,T.length()) {
      if (S[i + j] != T[j]) count++;
    }
    ans = min(ans, count);
  }

  cout << ans << endl;

  return 0;
}

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

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

int main(){
int a[3];
rep(i,3)
cin>>a[i];
sort(a,a+3);

if((a[1]-a[0])%2==0)
cout<<(a[1]-a[0])/2+a[2]-a[1]<<endl;
else
{
cout<<(a[1]-a[0])/2+a[2]-a[1]+2<<endl;
}



  return 0;
}


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

c = [0] * (N+1)

for i in range(N):
    c[i+1] = c[i] + A[i]
cnt = {}
for i in range(0,N+1):
    if c[i] not in cnt:
        cnt[c[i]] = 1
    else:
        cnt[c[i]] += 1
count = 0
for v in cnt.values():
    count += v * (v-1) // 2
print(count)


Measured memory_bytes: 41244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int t = Integer.parseInt(str[2]);

		int time = 0;
		int ans = 0;

		while (time + a <= t) {
			time += a;
			ans += b;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 32660
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
neg_diffs = []
pos_diffs = []
for a, b in zip(A, B):
    if a < b:
        neg_diffs.append(b - a)
    else:
        pos_diffs.append(a - b)
if len(pos_diffs) == N:
    print(0)
    exit()
cnt = 0
neg_sum = sum(sorted(neg_diffs))
for pos_diff in sorted(pos_diffs, reverse=True):
    if neg_sum <= 0:
        break
    neg_sum -= pos_diff
    cnt += 1
print(cnt + len(neg_diffs))


Measured memory_bytes: 19068
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 小数のときは，精度の設定する．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int64_t x; cin >> x;

cout << (x/11) * 2 + ((x%11 == 0) ? 0 : (x%11 <= 6 ? 1 : 2)) << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
n,l=map(int,input().split())
hoge=[]
for i in range(n):
  hoge.append(l+i)

  
if(hoge.count(0)==1):
  ans=0
elif(sum(hoge)>0):
  ans=min(hoge)
else:
  ans=max(hoge)

print(sum(hoge)-ans)

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

bool prime(int x){
    if(x <= 1) return false;
    for(int i = 2; i*i <= x; i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    
    while (!prime(n)) n++;

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3600
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())

l = []
for i in range(100//4):
    for j in range(100//7):
        if n == i*4+j*7:
            print("Yes")
            exit()
print("No")





Measured memory_bytes: 9184
def main():
    n, m = map(int, input().split())
    a=list(map(int, input().split()))
    s=[0]*(n+1)
    for i in range(1, n+1):
        s[i]=s[i-1]+a[i-1]
    dic={}
    for i in range(n+1):
        tmp=s[i]%m
        if tmp in dic.keys():
            dic[tmp]+=1
        else:
            dic[tmp]=1
    ans=0
    for i in dic.values():
        ans+=i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 16556
program main;
var s : array[1..100] of char;
    n,i,c : integer;
begin
  readln(n);
  for i := 1 to n do 
    read(s[i]);
    c := 0;
  for i := 1 to n do 
    if (s[i] = 'A') and (s[i+1] = 'B') and (s[i+2] = 'C') then inc(c);
  writeln(c);
end.

Measured memory_bytes: 1368
/*
  AUTHOR:SOURABH
  CREATED:09:02:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,n,k,v,i;
    ld sum,ans;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>k;
        vll a(n);
        fn(i,n)
        cin>>a[i];
        sum=ans=0;
        fn(i,k)
        sum+=(1.0*(a[i]+1))/2;
        ans=sum;
        fs(i,k,n)
        {
            sum-=((a[i-k]+1)*1.0)/2;
            sum+=(1.0*(a[i]+1))/2;
            ans=max(ans,sum);
        }
        cout<<fixed<<setprecision(12)<<ans<<"\n";
    }
    return 0;
}




























Measured memory_bytes: 1792
def bubblesort_re(A,N):
    count = 0
    #A[i] > A[i+1]の状態がある→交換する必要がある：flag = True
    #交換する必要が無いとbreak→値の無駄な比較をしない
    flag = True
    while flag:
        flag = False
        # for i in range(N-1):
        #     if A[i][1] > A[i+1][1]:
        #         A[i],A[i+1] = A[i+1],A[i]
        #         count += 1
        #         flag = True
        for i in range(N-1,0,-1):
            if A[i][1] < A[i-1][1]:
                A[i],A[i-1] = A[i-1],A[i]
                count += 1
                flag = True

    return A,count

def min_index(A):
    index = 0
    m = A[0][1]
    for i in range(1,len(A)):
        if A[i][1] < m:
            m = A[i][1]
            index = i

    return index

# def selectionsort(A,N):
#     count = 0
#     for i in range(N-1):
#         j = min_index(A[i+1:])
#         if int(A[i][1]) > int(A[i+j+1][1]):
#             A[i],A[i+j+1] = A[i+j+1],A[i]
#             count += 1
#
#     return A,count

def selectionsort(A,N):
    count = 0
    for i in range(N):
        minj = i
        #最小値を見つけるfor文：O(n)
        for j in range(i+1,N):
            if A[j][1] < A[minj][1]:
                minj = j
        A[i],A[minj] = A[minj],A[i]

    return A,count

if __name__ == '__main__':
    import copy

    N = int(input())
    A = input().split()

    X = A.copy()
    s,t = bubblesort_re(X,N)
    for i in range(N):
        if i != N - 1:
            print(s[i],end = " ")
        else:
            print(s[i])
    print("Stable")

    X = A.copy()
    u,v = selectionsort(X,N)
    for i in range(N):
        if i != N - 1:
            print(u[i],end = " ")
        else:
            print(u[i])
    if s == u:
        print("Stable")
    else:
        print("Not stable")



Measured memory_bytes: 6344
z['   '],i;
main(j){
	for(;++i<2e3;)
		if(!(z[i>>5]&1<<i))
			for(j=-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;scanf("%d",&i),i;)
		for(j=i-1>>1;i;j--)
			z[j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
	return 0;
}

Measured memory_bytes: 1016