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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

//#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x) { cout << x << endl; }
template<class T, class... A> void print(const T& first, const A& ... rest) { cout << first << " "; prll(rest...); }
struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } premain;


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

	ll l = 0;
	ll r = 0;
	for (auto s : S) {
		if ('(' == s) {
			l++;
		}
		else {
			if (0 < l) {
				l--;
			}
			else {
				r++;
			}
		}
	}

	std::string ans = "";
	for (int i = 0; i < r; i++) {
		ans += "(";
	}
	ans += S;
	for (int i = 0; i < l; i++) {
		ans += ")";
	}

	print(ans);
	return 0;
}


Measured memory_bytes: 256
import math
def main():
    N, K = map(int, input().split(' '))
    An = list(map(int, input().split(' ')))
    
    # N, K = 4, 3
    # An = [2, 3, 1, 4]
    
    # N, K = 8, 3
    # An = [7, 3, 1, 8, 4, 6, 2, 5]
    
    
    num = len(An)
    
    # print(num // (K-1))
    
    # for i in range(0, len(An), K-1):
    #     print(i)
    out = (N - 1) / (K - 1)
    print(math.ceil(out))
    
main()

Measured memory_bytes: 51948
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    string s,sta;
    int n,f=0;
    cin>>s>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(x==1)f==0?f=1:f=0;
        else if(x==2)
        {
            int y;
            string o;
            cin>>y>>o;
            if(y==1)
            {
                if(!f)o+=s,s=o;
                else reverse(o.begin(),o.end()),s+=o;
            }
            else if(y==2)
            {
                if(!f)s+=o;
                else reverse(o.begin(),o.end()),o+=s,s=o;
            }
        }
    }
    if(!f)cout<<s;
    else for(int i=s.size()-1;i>=0;i--)cout<<s[i];
}


Measured memory_bytes: 4092
s = list(input())

def check(c):
    if c not in s:
        return float('inf')

    cnt = 0
    ans = 0
    for i in s:
        if i==c:
            cnt = 0
        else:
            cnt += 1
        ans = max(ans, cnt)
    return ans

ans = float('inf')
for i in range(97, 97+26):
    c = chr((i))
    ans = min(ans, check(c))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vector<int> v(n);
	vector<int> cnt(n);
	for(int i=0; i<n; i++) cin>>v[i];
	for(int i=0; i<n; i++){
		if(i-v[i]>=0) cnt[i-v[i]]+=1;
	}
	ll answer=0;
	for(int i=0; i<n; i++){
		if(i+v[i]<n) answer+=cnt[i+v[i]];
	}
	cout<<answer;
    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	ll sa=abs(abs(a)-abs(b));
	ll ans=sa;
	if(a+sa==b){
		cout << ans;
		return 0;
	}
	if(a+sa==-b){
		cout << ans+1;
		return 0;
	}
	if(-a+sa==b){
		cout << ans+1;
		return 0;
	}
	if(-a+sa==-b){
		cout << ans+2;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define false 0
#define true 1

int PrimeNumber(int n)
{
    if(n<2)    return false;
    if(n == 2)  return true;
    if(n % 2 == 0)  return false;
    double sqnum = sqrt(n);
    
    for(int i = 3;i<=sqnum ;i += 2)
    {
        if(n % i == 0)
            return false;
        
    }
    
    
    return true;
}


int main()
{
    int num = 0;
    int count = 0;
    
    
    
    scanf("%d",&num);
    
    int val[num];
    for(int i = 0;i<num;i++)
    {
        scanf("%d",&val[i]);
        if(PrimeNumber(val[i]) == 1)
            count++;
    }
    printf("%d\n",count);
        return 0;
}



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


int main() {
    int n, x, t;
    cin >> n >> x >> t;

    if (n % x == 0) {
        cout << t * n / x << endl;
    } else {
        cout << t * (n / x) + t << endl;
    }
}


Measured memory_bytes: 3624
#include<stdio.h>

int number(int* a, int n){
    int sum = 0;
    for(int i=0; i<n; i++){
        sum += *(a+i);
    }
    return sum;
}

int main(){
    int n, y;
    scanf("%d %d", &n, &y);
    int a[3] = {0, 0, y/1000};
    while(n < number(a, 3)){
        int flag = 1;
        if(number(a, 3)-n >= 4 && a[2]/5 > 0 && flag == 1){
            a[2] -= 5;
            a[1] += 1;
            flag = 0;
        }
        if(number(a, 3)-n >= 1 && a[1]/2 > 0 && flag == 1){
            a[1] -= 2;
            a[0] += 1;
            flag = 0;
        }
        if(flag == 1){
            break;
        }
    }

    if(n == number(a, 3)){
        printf("%d %d %d", a[0], a[1], a[2]);
    }else{
        printf("-1 -1 -1");
    }

    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse

    def div(self, x, y):
        """ MOD除算 """

        return x * pow(y, self.MOD-2, self.MOD) % self.MOD

N = INT()
A = [0] + LIST()
B = [A[i+1] - A[i] for i in range(N)]

mt = ModTools(N, MOD)
add = mt.fact[N-1]
# スライムが区間iを通る合計回数をそれぞれ求める
cnt = [0] * N
for i in range(1, N):
    cnt[i] = cnt[i-1] + add
    cnt[i] %= MOD
    add *= mt.div(i , (i+1))
    add %= MOD

ans = 0
for i in range(1, N):
    # 区間長を掛ければ合計距離
    ans += B[i] * cnt[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 22976
#include <iostream>
#include <cstring>

using namespace std;

int N, W;

int v[1010], w[1010];

int dp[2][1010];

void solve() {
	memset(dp, 0, sizeof(dp));
	
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		int nw = i%2, nx = (i+1)%2;
		for (int j = 0; j <= W; j++) {
			dp[nx][j] = max( dp[nx][j], dp[nw][j] );
			if (j + w[i] <= W) dp[nx][ j + w[i] ] = max( dp[nw][ j + w[i] ], dp[nw][ j ] + v[i]);
		}
	}
	
	int ansv = 0, answ;
	for (int i=0; i<=W; i++) {
		if (ansv < dp[N%2][i]) {
			ansv = dp[N%2][i];
			answ = i;
		}
	}
	cout << ansv << endl;
	cout << answ << endl;
}

int main() {
	int cnum = 0;
	
	while (1) {
		cin >> W; if (W==0) break;
		cnum++;
		
		cin >> N;
		char c;
		for (int i=0; i<N; i++) cin >> v[i] >> c >> w[i];
		
		cout << "Case " << cnum << ":" << endl;
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>

int main(void) {
    int N,K,l[50],max=0,i,j,temp;
    
    scanf("%d %d",&N,&K);
    
    for(i=0;i<N;i++){
        scanf("%d",&l[i]);
    }
    
    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            if(l[i]<l[j]){
                temp=l[i];
                l[i]=l[j];
                l[j]=temp;
            }
        }
    }
    
    for(i=0;i<K;i++){
        max=max+l[i];
    }
    
    printf("%d\n",max);
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());

	for (int i = 0; i < s.length()-1; i++) {
		if (s[i] == s[i + 1])return cout << "no" << endl,0;
	}

	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
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; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int a,b;
	cin >> a >> b;
	int x = 6-(a+b);
	cout << x << endl;


  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


n = int(input())
digi = len(str(n))
ans = 0
if not bool(n&1):
    for i in range(1,50):
        ans += n//(5**i)//2

print(ans)


Measured memory_bytes: 13772
#include<stdio.h>
#include<stdlib.h>

int min(int a, int b){
        if(a < b) return a;
        else return b;
}

int main(){
        int n;
        scanf("%d", &n);
        int h[n];
        for(int i=0; i<n; i++) scanf("%d", &h[i]);

        int dp[n];
        for(int i=0; i<n; i++) dp[i] = 1e9;
        dp[0] = 0;

        for(int i=0; i<n; i++){
                if(i >= 1){
                        dp[i] = min(dp[i], dp[i-1] + abs(h[i-1]-h[i]));
                }
                if(i >= 2){
                        dp[i] = min(dp[i], dp[i-2] + abs(h[i-2]-h[i]));
                }
        }
        printf("%d\n", dp[n-1]);
        return 0;
}

Measured memory_bytes: 2476
<?php
// C
fscanf(STDIN, '%s', $s);
fscanf(STDIN, '%d', $k);
$N = 5 * (10 ** 12);
$n = strlen($s);
for ($i = 0; $i < $n; $i++) {
    $x = (int) $s[$i];
    if ($x ** $N >= $k) {
        $ans = $x;
        break;
    } else {
        $k -= $x ** $N;
    }
}
echo $ans;

Measured memory_bytes: 4856
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int ab = Integer.parseInt(a + b);
		if(Math.sqrt(ab)  % 1 == 0) System.out.println("Yes");
		else System.out.println("No");
        sc.close();
	}
}

Measured memory_bytes: 21716
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = get!();
    for _ in 1..n {
    	let x = get!();
        ans = gcd(ans, x);
    }
    
    println!("{}", ans);
}

fn gcd(a: i64, b: i64) -> i64 {
	fn _gcd(a: i64, b: i64) -> i64 {
    	if a == 0 {
        	return b;
        }
        _gcd(b % a, a)
    }
    if a < b {
    	_gcd(a, b)
    } else {
    	_gcd(b, a)
    }
}

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

int main() {
    int N, X;
    cin >> N >> X;
    while (N != 0 || X != 0) {
    long long ans = 0;
    for (int i = 1; i <= N - 2; i++) {
        for (int j = i + 1; j <= N - 1; j++) {
            for (int k = j + 1; k <= N; k++) {
                if (i + j + k == X) ans++;
            }
        }
    }
    cout << ans << endl;
    cin >> N >> X;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> cnt(4);
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        cnt[x]++;
    }
   double dp[n+1][n+1][n+1];
    memset(dp,0,sizeof dp);
    for(int three=0;three<=n;three++)
    {
        for(int two=0;two<=n;two++)
        {
            for(int one=0;one<=n;one++)
            {
                double c=one+two+three;
                double z = n-c;
                if(c>n||c==0)
                continue;
                double val = 1.0;
                val+=(1.0)*one/n*dp[one-1][two][three];
                val+=(1.0)*two/n*dp[one+1][two-1][three];
                val+=(1.0)*three/n*dp[one][two+1][three-1];
                val = 1.0*val/(1.0-1.0*z/n);
                dp[one][two][three] = val;
            }
        }
    }
    cout<<setprecision(10)<<fixed;
    cout<<dp[cnt[1]][cnt[2]][cnt[3]];
}


Measured memory_bytes: 216668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int h,w;
  char c;
  cin>>w>>h>>c;
  rep(i,h){rep(j,w){
    if((!i&&(!j||j==w-1))||!j&&i==h-1||(i==h-1&&j==w-1))cout<<'+';
    else if(!i||i==h-1)cout<<'-';
    else if(!j||j==w-1)cout<<'|';
    else if(h/2==i&&w/2==j)cout<<c;
    else cout<<'.';
  } cout<<endl; }
}

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

using namespace std;

#define lli long long 
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000000007

int main(){
        lli n,m=MAX;
        cin >> n;
        rep1(i,sqrt(n)){
        if(n%i==0){
              m=min(n/i+i-2,m);
               
        }
        }

        cout << m;
}


Measured memory_bytes: 256
inf = 10 ** 16

n = int(input())
a = tuple(int(x) for x in input().split())

d = [[inf] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0

c = [0]
for aa in a:
    c.append(c[-1] + aa)

for i in range(n - 1, -1, -1):
    for j in range(i + 1, n):
        for k in range(i, j):
            # [i, k], (k, j]
            d[i][j] = min(d[i][j], d[i][k] + d[k + 1][j])
        d[i][j] += c[j + 1] - c[i]
# print(d)
# print(c)
print(d[0][n - 1])


Measured memory_bytes: 42732
#include<cstdio>
#include<cstring>
#include<map>

inline int Abs(const int x) { return x >= 0 ? x : -x; }

int n, a[205], b[205], mat[205], ans;
bool G[205][205], vis[205];
std::map<int, int>mp;

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

bool dfs(int x) {
	for (int y = 1; y <= n; y++) {
		if (!vis[y] && G[x][y]) {
			if (vis[y] = true, !mat[y] || dfs(mat[y])) {
				return mat[y] = x, true;
			}
		}
	}
	return false;
}

int main() {
	scanf("%d", &n);
	for (int i = 1, x; i <= n; i++)scanf("%d", &x), mp[x] ^= 1, mp[x + 1] ^= 1;
	for (auto& i : mp)if (i.second)(i.first & 1 ? a[++ * a] : b[++ * b]) = i.first;
	for (int i = 1; i <= *a; i++) {
		for (int j = 1; j <= *b; j++) {
			G[i][j] = prime(Abs(a[i] - b[j]));
		}
	}
	for (int i = 1; i <= *a; i++)memset(vis, 0, sizeof vis), ans += dfs(i);
	printf("%d\n", ans + (*a - ans) / 2 * 2 + (*b - ans) / 2 * 2 + (*a - ans) % 2 * 3);

	return 0;
}

Measured memory_bytes: 256
import copy

def BubbleSort(arr):
	n=len(arr)
	for i in range(n):
		for j in range(n-1,i,-1):
			if int(arr[j][1])<int(arr[j-1][1]):
				arr[j],arr[j-1]=arr[j-1],arr[j]
	return arr

def SelectionSort(arr):
	n=len(arr)
	for i in range(n):
		minp=i
		for j in range(i,n):
			if int(arr[j][1])<int(arr[minp][1]):
				minp=j
		arr[minp],arr[i]=arr[i],arr[minp]
	return arr
  
def IsStable(basearr,resultarr):
  checkarr1=[[] for _ in range(14)]
  checkarr2=[[] for _ in range(14)]
  for i in range(len(basearr)):
    checkarr1[int(basearr[i][1])].append(basearr[i][0])
    checkarr2[int(resultarr[i][1])].append(resultarr[i][0])
  if checkarr1==checkarr2:
    print('Stable')
  else:
    print('Not stable')
  

n=int(input())
arr=list(map(str,input().split()))
bubble=BubbleSort(copy.deepcopy(arr))
selection=SelectionSort(copy.deepcopy(arr))
print(' '.join(map(str,bubble)))
IsStable(arr,bubble)
print(' '.join(map(str,selection)))
IsStable(arr,selection)


Measured memory_bytes: 6348
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}

fn main() {
    let n = read::<i32>();
    if n == 1 {
        println!("Hello World");
    }
    else {
        let a = read::<i32>();
        let b = read::<i32>();
        println!("{}",a+b);
    }
}


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

int main(){
  string s;
  cin>>s;
  int count=0;
  for(int i=0;i<3;i++){
    if(s[i]=='A'){
      count++;
    }else if(s[i]=='B'){
      count--;
    }
  }

  if(count==3 || count==-3){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 256
#coding:UTF-8

while(True):
    try:
        n = map(float, raw_input().split())
        x = (n[2]*n[4] - n[5]*n[1]) / (n[0]*n[4] - n[3]*n[1])
        y = (n[2]*n[3] - n[5]*n[0]) / (n[1]*n[3] - n[4]*n[0])

        if x==-0:
            x=0
        if y==-0:
            y=0

        print "%.3f %.3f"%(x,y)

    except Exception:
        break

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

ll exp(ll a,ll n){
  if(n==0) return 1;
  else if(n%2==0) return (exp(a,n/2)*exp(a,n/2))%mod;
  else return (a*exp(a,n-1))%mod;
}

int main() {
  ll x,y;
  cin>>x>>y;
  ll ans;
  ll a=2*y-x;
  ll b=2*x-y;
  if((a>=0 && a%3==0) && (b>=0 && b%3==0)){
    a/=3;
    b/=3;
    ll p=1;
    ll q=1;
    for(int i=0;i<b;i++){
      p*=a+b-i;
      p%=mod;
      q*=i+1;
      q%=mod;
    }
    ll qq=exp(q,mod-2);
    ans=p*qq;
    ans%=mod;
  }
  else ans=0;
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
N, M = map(int, input().split())
X = []
for _ in range(M):
    p, s = input().split()
    X.append((int(p), s))

cnt = [[0, 0] for _ in range(N + 1)]
for p, s in X:
    if s == "AC":
        cnt[p][0] = 1
    elif cnt[p][0] == 0:
        cnt[p][1] += 1

ac = sum(v for v, _ in cnt)
wa = 0
for i in range(N + 1):
    if cnt[i][0] == 1:
        wa += cnt[i][1]
print(ac, wa)


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define pr(a,b) cout << a << " " << b << endl
#define pr1(a,b,c) cout << a << " " << b << " "<< c << endl
#define int long long

int32_t main()
{
	fastio;
	int n,k;
	cin >> n >> k;
	int cnt1 = 0, cnt2 = 0;
	int i;
	for(i=1;i<=n;i++)
	{
		if(i%k==0)
			cnt1++;
		else if(i%k==k/2)
			cnt2++;
	}
	int ans = 0 ;
	ans = cnt1*cnt1*cnt1;
	if(k>1 && k%2==0)
		ans += cnt2*cnt2*cnt2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = list(map(int,list(input())))
check = [[0 for i in range(3)] for j in range(1 << 3)]

for i in range(1 << 3):

    for j in range(3):
        if ((i >> j) & 1) == 1:
            check[i][j] = '+'
        else:
            check[i][j] = '-'

for i in check:
    sum = s[0]
    ans = str(s[0])
    for j in range(3):
        if i[j] == '+':
            sum += s[j+1]
            ans += '+'+str(s[j+1])
        else:
            sum -= s[j+1]
            ans += '-'+str(s[j+1])

    if sum == 7:
        print(ans + '=7')
        exit()


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

char tolower(char);

int main(){
  string w;
  string t;
  string eof="END_OF_TEXT";
  cin >> w;
  int counter=0;

  while(true){
    cin >> t;
    if(t==eof) break;
    for(int i=0; i<t.size(); i++){
      t[i] = tolower(t[i]);
    }
    if(t==w) counter++;
  }
  cout << counter << endl;
}

char tolower(char c){
  if(c>='A'&&c<='Z')c+=32;//大文字を小文字に
  return c;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 998244353
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    ll d[n], D[n];
    for(int i = 0; i < n; i++) d[i] = 0;
    for(int i = 0; i < n; i++){
        cin >> D[i];
        d[D[i]]++;
    }
    if(D[0] != 0){
        cout << 0 << endl; return 0;
    }
    if(d[0] != 1){
        cout << 0 << endl; return 0;
    }
    ll ans = 1;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < d[i]; j++){
            ans *= d[i-1]; ans %= mod;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

const ll INF = 1LL << 58;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M, L;
  cin >> N >> M >> L;
  vector<vector<ll>> A(N, vector<ll>(N, INF));
  for (int i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    A[a][b] = A[b][a] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
      }
    }
  }
  vector<vector<ll>> B(N, vector<ll>(N, INF));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i][j] <= L) B[i][j] = 1;
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
      }
    }
  }
  ll Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    ll s, t;
    cin >> s >> t;
    s--, t--;
    cout << (B[s][t] != INF ? B[s][t] - 1 : -1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int getFloorNum(double h) {
    return ceil(h / 5.0) + 1;
}

int main() {
    double v;
    while(cin >> v) {
        double h = v*v/19.6;
        cout << getFloorNum(h) << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {

int a,b;

string op;

do{

cin >> a >> op >> b;

if(op=="+"){cout << a+b << endl;}
if(op=="-"){cout << a-b << endl;}
if(op=="*"){cout << a*b << endl;}
if(op=="/"){cout << a/b << endl;}
if(op=="?"){break;}
}while(op!="/" || b!=0);

}


Measured memory_bytes: 3144
#include<stdio.h>
int main(void)
{
	int n;
	int a;
	long long int s;
	int i;
	s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		s+=a;
	}
	s=s/n;
	printf("%d\n",s);
	return 0;
}
	

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll mypow(ll a, ll x) {
  ll ret = 1ll;
  while (x) {
    if (x & 1) ret *= a;
    a *= a;
    x >>= 1;
  }
  return ret;
}

vector<ll> roots(ll x) {
  vector<ll> res({x});
  for (int i = 2; i < 43; i++) {
    double X = x;
    double cand = pow(x, 1.0 / i);
    ll cand_ll = (ll)cand;
    for (ll c = max(2ll, cand_ll - 2); c <= cand_ll + 2; c++) {
      if (mypow(c, i) == x) {
        res.push_back(c);
        break;
      }
    }
  }
  return res;
}

void solve() {
  ll N;
  cin >> N;
  vector<ll> ps = divisor(N);
  vector<ll> qs = divisor(N - 1ll);
  //   dmp(ps);
  //   dmp(qs);
  set<ll> s;
  for (ll div : ps) {
    if (div == 1ll) continue;
    vector<ll> rs = roots(div);
    for (ll r : rs) {
      ll tmp = N;
      while (tmp % r == 0ll) tmp /= r;
      if (tmp % r == 1ll) s.insert(r);
    }
  }
  // for (int val : s) { cout << val << endl; }
  cout << s.size() + qs.size() - 1 << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

typedef long long ll;
typedef long double ld;

ll n,k,r,w,q,qq,p;
multiset<ll> z,zz;
bool b;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    ll x[n];
    for(ll i=0;i<n;i++) cin>>x[i],r+=x[i];

    for(ll i=1;i*i<=r;i++){
        if(r%i!=0) continue;
        w=r/i;
        z.clear();
        zz.clear();
        q=0;
        qq=0;
        p=0;
        b=true;
        for(ll j=0;j<n;j++){
            if(x[j]%w<(w-x[j]%w) || (x[j]%w==(w-x[j]%w) && b)){
                z.insert(x[j]%w);
                q+=x[j]%w;
                if(x[j]%w==(w-x[j]%w)) b=false;
            }
            else{
                zz.insert(w-x[j]%w);
                qq+=w-x[j]%w;
                if(x[j]%w==(w-x[j]%w)) b=true;
            }
        }
        while(q!=qq){
                if(q>qq){
                    if(z.size()==0) break;
                    auto t=z.rbegin();
                    q-=*t;
                    qq+=(w-*t);
                    z.erase(z.find(*t));
                }
                else{
                    if(zz.size()==0) break;
                    auto t=zz.rbegin();
                    qq-=*t;
                    q+=(w-*t);
                    zz.erase(zz.find(*t));
                }
        }

        if(q==qq && q<=k){
            cout<<w;
            return 0;
        }
    }


    for(ll i=sqrt(r);i>=1;i--){
        if(r%i!=0) continue;
        w=i;
        z.clear();
        zz.clear();
        q=0;
        qq=0;
        p=0;
        b=true;
        for(ll j=0;j<n;j++){
            if(x[j]%w<(w-x[j]%w) || (x[j]%w==(w-x[j]%w) && b)){
                z.insert(x[j]%w);
                q+=x[j]%w;
                if(x[j]%w==(w-x[j]%w)) b=false;
            }
            else{
                zz.insert(w-x[j]%w);
                qq+=w-x[j]%w;
                if(x[j]%w==(w-x[j]%w)) b=true;
            }
        }
        while(q!=qq){
                if(q>qq){
                    if(z.size()==0) break;
                    auto t=z.rbegin();
                    q-=*t;
                    qq+=(w-*t);
                    z.erase(z.find(*t));
                    p+=*t;
                }
                else{
                    if(zz.size()==0) break;
                    auto t=zz.rbegin();
                    qq-=*t;
                    q+=(w-*t);
                    zz.erase(zz.find(*t));
                    p+=*t;
            }
        }

        if(q==qq && q<=k){
            cout<<w;
            return 0;
        }
    }
    cout<<n;


}


Measured memory_bytes: 3704
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    #define pi 3.14159265359
    
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll r;
            cin>>r;
            ld ans=2*pi*r;
            printf("%.9Lf\n",ans);
        }
        return 0;
    }


Measured memory_bytes: 3788
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<algorithm>
using namespace std;
long long N;
long long A[100001],B[100001],C[100001];
int main() {
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int j=0;j<N;j++){
		cin>>B[j];
	}
	for(int k=0;k<N;k++){
		cin>>C[k];
	}

	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);

	long long R=0;
	for(int i=0;i<N;i++){
		long long H=lower_bound(A,A+N,B[i])-A;
		long long V=upper_bound(C,C+N,B[i])-C;
		R+=H*(N-V);

	}


	cout<<R<<endl;

	return 0;
}


Measured memory_bytes: 2688
a, b, k = [int(x) for x in input().split(" ")]

if a + b == k or a + b < k or (a == 0 and b == 0):
  print(0, 0)
elif a + b > k and a >= k:
  print(a-k, b)
elif a + b > k and a < k:
  print(0, a+b-k)


Measured memory_bytes: 2940
#include <stdio.h>
int main(void)
{
int W, H, x, y, r;

scanf("%d", &W);
scanf("%d", &H);
scanf("%d", &x);
scanf("%d", &y);
scanf("%d", &r);

if(x >= 0 && y >= 0){

  if( x < W && y < H && x >= r && y >= r){
    printf("Yes\n");
     }
  else {
   printf("No\n");
   }
 }
else{
  printf("No\n");
}   

return 0;
}

Measured memory_bytes: 584
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int T = int.Parse(str[2]);
		Console.WriteLine(T/A*B);
	}
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int max = 999999999;
        long sum = 0;
        for(int i=0;i<N;i++){
            int now = sc.nextInt();
            if(now<max){
                max = now;
                sum++;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 64992
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int dp[1010][1010] = {{0}};
int W,n;
int w[1010] = {0},p[1010] = {0};
int cnt = 0;
int wm = 0,nc;
int main()
{
    while(1){
        cin >> W;
        if(W == 0) break;
        cnt++;
        cin >> n;
        for(int i = 0; i < n; i++) scanf("%d,%d",&p[i],&w[i]);
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= W; j++){
                if(j < w[i]) dp[i+1][j] = dp[i][j];
                else dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+p[i]);
            }
        }
        nc = W;
        while(nc >= 0){
            if(dp[n][nc] == dp[n][W])
                wm = nc;
            nc--;
        }
        cout << "Case " << cnt << ':' << endl << dp[n][W] << endl << wm << endl;
    }
	return 0;
}

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

using namespace std;

int main (void) {
    long long x;
    cin >> x;

    long long ans = ((x - 1) / 11 + 1) * 2;
    if ( x <= 11 * (ans / 2) - 5 )
        ans--;

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


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
int N,A,B,C;
vector<int> L;

void chmin(int &a, int b){
  if (a > b){
    a = b;
  }
}

int rec(int,int,int,int);
int main(){
  cin >> N >> A >> B >> C;
  L.resize(N);
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  cout << rec(0,0,0,0) << endl;
}
int rec(int i,int a,int b,int c){
  if(i==N){
    if(!a || !b || !c){
      return 1000000;
    }
    return abs(a-A)+abs(b-B)+abs(c-C);
  }

  int res = rec(i+1,a,b,c);

  chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
  chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
  chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
  return res;
}

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

int main(){
	int n;
	cin>>n;
	set<int>s;
	set<int>::iterator it; 
	while(n--){
		int a;
		cin>>a;
		it = s.find(a);
		if(it!=s.end()) s.erase(it);
		else s.insert(a);
	}
	cout<<s.size();	
}

Measured memory_bytes: 8168
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#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 a,b;
void solve()
{
	cin>>a>>b;
	

	if (b-a<5000)
	{
		int ans=(a*b)%2019;

	rep(i,a,b+1)
	{
		rep(j,i+1,b+1)ans=min(ans,(i*j)%2019);
	}
	cout<<ans<<"\n";return;

	}
	cout<<"0\n";return;
	a%=2019;b%=2019;

	if (a>b)swap(a,b);
	int ans=(a*b)%2019;

	rep(i,a,b)
	{
		rep(j,i,b)ans=min(ans,(i*j)%2019);
	}
	cout<<ans<<"\n";
	

}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
 
    #ifdef local
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 
    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: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long int
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fi first
#define se second
int main()
{
  fastIO
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll dp[n];
  for(ll i=0;i<n;i++)
    dp[i]=INT_MAX;
  dp[0]=0;
  for(ll i=1;i<n;i++)
  {
    ll count=0;
    for(ll j=i-1;j>=0&&count!=k;j--)
    {
      count++;
      dp[i]=min(dp[i],(dp[j]+abs(a[i]-a[j])));
    }
  }
  /*for(ll i=0;i<n;i++)
    cout<<dp[i]<<" ";*/
  cout<<dp[n-1]<<"\n";
  return 0;
}


Measured memory_bytes: 1920
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Fib[45];

int main(){
  Fib[0] = 1; Fib[1] = 1;
  for (int i = 2; i < 45; i++){
    Fib[i] = Fib[i - 2] + Fib[i - 1];
  }
  int N; cin >> N;
  cout << Fib[N] << endl;

  return 0;
}



Measured memory_bytes: 3120
input()
C = [[x[0], x[1]] for x in list(input().split())]
D = C.copy()
N = len(C)

# バブルソート
for i in range(0, N-1, 1):
    for j in range(N-1, i, -1):
        if C[j][1] < C[j-1][1]:
            tmp = C[j]
            C[j] = C[j-1]
            C[j-1] = tmp

# 選択ソート
for i in range(0, N-1, 1):
    minj = i
    for j in range(i, N, 1):
        if D[j][1] < D[minj][1]:
            minj = j
    tmp = D[i]
    D[i] = D[minj]
    D[minj] = tmp

# バブルソートの結果出力
length = len(C)
for i in range(length):
    if i == length - 1:
        print("".join(C[i]), end="")
    else:
        print("".join(C[i]), end=" ")

print("")
print("Stable")

# 選択ソートの結果出力
for i in range(length):
    if i == length - 1:
        print("".join(D[i]), end="")
    else:
        print("".join(D[i]), end=" ")

print("")
if C == D:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n,k;
cin >> n >> k;
  vector<int> v(n);
   for(int i = 0;i < n;i++){
     cin >> v.at(i);
   }
  int uu = 0;
  for(int i = 0;i < min(k+1,n+1);i++){
    for(int j = 0;j < min(k-i+1,n+1-i);j++){
      vector<int> a;
      for(int l = 0;l < i;l++){
        a.push_back(v.at(l));}
       for(int l = 0;l < j;l++){
         a.push_back(v.at(n-l-1));}
      sort(a.begin(),a.end());
      int yyyy = a.size();
      int f = min(k-i-j,yyyy);
         for(int l = 0;l < f;l++){
           if(a.at(l) < 0){a.at(l) = 0;}
           else{break;}
         }
      int r = 0;
        for(int l = 0;l < a.size();l++){
          r += a.at(l);}
      uu = max(uu,r);
    }
  }
      cout << uu << endl;
}

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

using namespace std;

class Dice{
	private:
		int label[6];
	public:
		void initialize(int number[]);
		void command(char houkou);
		int getResult();
};

//ラベルに数字を代入
void Dice::initialize(int number[])
{
	for(int i = 0; i < 6; i++){
		label[i] = number[i];
	}
}

//命令を実行
void Dice::command(char houkou)
{
	int temp[6];
	for(int i = 0; i < 6; i++) {
		temp[i] = label[i];
	}
	
	if(houkou == 'E'){
		label[0] = temp[3];
		label[2] = temp[0];
		label[3] = temp[5];
		label[5] = temp[2];
	}
	else if(houkou == 'W'){
		label[0] = temp[2];
		label[2] = temp[5];
		label[3] = temp[0];
		label[5] = temp[3];
	}
	else if(houkou == 'N'){
		label[0] = temp[1];
		label[1] = temp[5];
		label[4] = temp[0];
		label[5] = temp[4];
	}
	else if(houkou == 'S'){
		label[0] = temp[4];
		label[1] = temp[0];
		label[4] = temp[5];
		label[5] = temp[1];
	}
}

//結果を取得
int Dice::getResult()
{
	return label[0];
}

int main(){
	Dice dice;
	int number[6];
	for(int i = 0; i < 6; i++){
		cin >> number[i];
	}
	dice.initialize(number);
		
	string meirei;
	cin >> meirei;
	for(int i = 0; i < meirei.length(); i++){
		dice.command(meirei[i]);
	}
	cout << dice.getResult() << endl;
	
	return 0;
}

Measured memory_bytes: 1204
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, W, H;
int a[100002], b[100002];
signed main() {
	cin >> n >> H >> W;
	for (int i = 0; i < n; i++) {
		int x, y, w;
		cin >> x >> y >> w;
		a[max(1, x - w + 1)]++; a[min(H + 1, x + w + 1)]--;
		b[max(1, y - w + 1)]++; b[min(W + 1, y + w + 1)]--;
	}
	bool l = a[1], m = b[1];
	for (int i = 1; i <= H; i++) {
		a[i] += a[i - 1];
		if (a[i] <= 0) l = 0;
	}
	for (int i = 1; i <= W; i++) {
		b[i] += b[i - 1];
		if (b[i] <= 0) m = 0;
	}
	if (l||m) cout << "Yes\n";
	else cout << "No\n";
	getchar(); getchar();
}


Measured memory_bytes: 3876
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
		//		new Main().solveE();
		//		new Main().solveF();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println(numN / 3);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveE() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveF() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

typedef signed long long ll;
const int N = 2e3 + 5;
int A[N];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; scanf("%d", &A[i]), i++);
	sort(A, A + n);
	ll tot = ((ll)n * (ll)(n - 1) * (ll)(n - 2)) / 6;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int cnt = n - (lower_bound(A, A + n, A[i] + A[j]) - A);
			tot -= cnt;
		}
	}
	printf("%lld\n", tot);
	return 0;
}

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

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,res=INT_MIN,p=INT_MAX;
    cin >> a >> b >> c;
    if(p > a) p = a;
    if(p > b) p = b;
    if(p > c) p = c;
    if(a > res) res = a;
    if(b > res) res = b;
    if(c > res) res = c;
    cout << p <<" " << res << endl;
    return 0;
}



Measured memory_bytes: 3220
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    string s;
    cin >> s;

    int n=s.size();

    if(s[0]==s[n-1] && n%2==1){
        cout << "Second" << endl;
    }else if(s[0]==s[n-1] && n%2==0){
        cout << "First" << endl;
    }else if(s[0]!=s[n-1] && n%2==1){
        cout << "First" << endl;
    }else if(s[0]!=s[n-1] && n%2==0){
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 3716