akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		if(a==3||a==5||a==7){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
        scan.close();
	}
}

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

using namespace std;

int main(){
        long long n, m;
        long long sum = 0;
        cin >> n >> m;
        for(long long i = 0; i < m; i++){
                long long a;
                cin >> a;
                sum += a;
        }
        long long sol = (n - sum >= 0) ? n - sum : - 1;
        cout << sol << '\n';
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    int64_t t = n%k;
    cout << min(t,k-t) << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:27:19 2019

@author: screamLab
"""

s = input()
s += 'H'
atcg = ['A','T','C','G']
ans = 0
long = 0
for i in range(len(s)):
    if s[i] in atcg:
        if i == len(s):
            break
        if s[i+1] in atcg:
            ans += 1
        else:
            ans += 1
            long = max(long,ans)
            ans = 0
long = max(long,ans)
print(long)
        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
int main()
{
    int a,b,d;
    cin >> a >> b;
    d = b - a;
    int sum = 0;
    for(int i = 1;i < 1000;i++)
    {
        sum+=i;
        if(i == d)
            break;
    }
    cout << sum - b << endl;;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<stdlib.h>
using namespace std;
int main()
{
	int N, sum1 = 0, sum2 = 0, count = 0;;
	int W[110];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &W[i]);
	}
	int i = 0, j = N-1 ;
	count = N;
	while (count > 0) {
		if (sum1 >= sum2) {
			sum2 += W[j];
			j--;
		}
		else {
			sum1 += W[i];
			i++;
		}
		count--;
	}
	printf("%d", abs(sum1 - sum2));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define debug(x) cout << #x << "==" << x << endl;

const int INF = 1e+8;

using namespace std;

//入力
#define MAX_N 100
#define MAX_M 100
int N;
int T[MAX_N];
int M;
int P[MAX_M], X[MAX_M];

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

  cin >> N;
  for(int i = 0; i < N; i++) { cin >> T[i]; }
  cin >> M;
  for(int i = 0; i < M; i++) { cin >> P[i] >> X[i]; }


  // ドリンクを飲まなかったときの合計
  int sum = 0;
  for(int i = 0; i < N; i++) { sum += T[i]; }

  int res = 0;
  for(int i = 0; i < M; i++) {

    int drink_i = P[i] - 1;

    res = sum - (T[drink_i] - X[i]);

    cout << res << "\n";

  }

  return 0;
}


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

int main() {
	int ans=0;
	string N;
	cin >> N;
	rep(i,N.size())if(N[i] == '2')ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX_N 100010
vector< pair<long long, long long> > dp(MAX_N, make_pair(1, 1));
vector<int> v[MAX_N];
vector<bool> used(MAX_N, false);

void dfs(int i) {
    used[i] = true;
    for (int j = 0; j < v[i].size(); j++) {
        if (used[v[i][j]]) continue;
        dfs(v[i][j]);
        dp[i].first *= (dp[v[i][j]].first + dp[v[i][j]].second) % mod; dp[i].first %= mod;
        dp[i].second *= dp[v[i][j]].first; dp[i].second %= mod;
    }
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int x, y; cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1);
    cout << (dp[1].first + dp[1].second) % mod << endl;
    return 0;
}

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

int main() {
    vector<bool> a(26,false);
    string s; cin >> s;
    if(s.size()<26){
        for(int i = 0; i < s.size(); i++) {
            a[(int)s[i]-97]=true;
        }
        for(int i = 0; i < 26; i++) {
            if(a[i]==false){
                s += (char)(97+i);
                cout << s << endl;
                return 0;
            }
        }
    }
    else{
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout << -1 << endl;
            return 0;
        }
        string t=s;
        string ans;
        next_permutation(t.begin(),t.end());
        for(int i = 0; i < 26; i++) {
            ans += t[i];
            if(s[i]!=t[i]) break;
        }
        cout << ans << endl;
        
    }

    return 0;
}

Measured memory_bytes: 3620
n = input()
p = []
input_first = input()
for ki in range(int(n)):
    p = input_first.rstrip().split(' ')
count = 0
for i in range(1,int(n)-1):
    if int(p[i]) > int(p[i-1]) and int(p[i]) < int(p[i+1]):
        count += 1
    elif int(p[i]) < int(p[i-1]) and int(p[i]) > int(p[i+1]):
        count += 1
    else:
        pass
print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{

	int n;
	cin >> n;

	vector<int> h(n);

	rep(i, n) cin >> h[i];


	bool f = false;
	int ans = 0;
	int preans = 0;
	for (int i = 1; i < n; i++)
	{
		if (h[i] <= h[i - 1]) preans++;

		else
		{
			ans = max(ans, preans);
			preans = 0;

		}
	}

	ans = max(ans, preans);


	cout << ans << endl;

}
	

Measured memory_bytes: 640
a, b, k = gets.chop.split.map(&:to_i)

re = []
right = a + k - 1
right = b if right >= b
left = b - k + 1
left = a if left <= a

for i in [*a..right]
  re << i
end
for i in [*left..b]
  re << i
end

puts re.uniq


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}
int main() {
	int n;
	cin >> n;
	VE vec(n);
	REP(i, n) {
		cin >> vec[i];
	}
	int nex = 1;
	int ans = 0;
	REP(i, n) {
		if (vec[i] == nex) {
			++nex;
		}
		else {
			++ans;
		}
	}
	if (nex == 1) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


Measured memory_bytes: 1024
A = [ list( map( int, input().split())) for _ in range(3)]
ans = "YES"
for t in range(1,5):
    for i in range(3):
        if A[i][1] == t or A[i][0] == t:
            pass
        else:
            break
    else:
        ans = "NO"
print(ans)


Measured memory_bytes: 3060
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	int N;
	int P[200001] = {};
	int ans=0;
	int mini = 999999;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> P[i];
	}
	mini = P[0];
	++ans;
	for (i = 1; i < N; ++i) {
		if (mini >= P[i]) {
			mini = P[i];
			++ans;
		}
	}
	cout << ans<<endl;


}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  vi a(m);
  rep(i,m)cin>>a[i];
  reverse(all(a));
  vi used(n,0);
  rep(i,m){
    a[i]--;
    if(used[a[i]]==0){
      cout<<a[i]+1<<endl;
      used[a[i]]++;
    }
  }
  rep(i,n)if(used[i]==0)cout<<i+1<<endl;
}

Measured memory_bytes: 3880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=2e5;

int main(){
	lli N;
	cin>>N;
	lli A[MAX+2];
	lli B[MAX+2];
	rep1(i,N){
		cin>>A[i];
		B[A[i]]=i;
	}
	
	lli ans=0;
	set<lli> s,t;
	s.insert(N+1);
	t.insert(0);
	rep1(i,N){
		set<lli>::iterator it,it2;
		it=s.upper_bound(B[i]);
		it2=t.upper_bound(-B[i]);
		lli r=*it;
		lli l=-*it2;
		ans+=i*(r-B[i])*(B[i]-l);
		s.insert(B[i]);
		t.insert(-B[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 22144
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = replicateM 5 readLn >>= print . solve

solve :: [Int] -> Int
solve = sum . edit . sortBy cmpf
    where
        cmpf lhs rhs = compare l r
            where
                l 
                    | lm > 0 = lm
                    | otherwise = 9
                r 
                    | rm > 0 = rm
                    | otherwise = 9
                lm = lhs `mod` 10
                rm = rhs `mod` 10
        edit (x : xs) = x : map mf xs
        mf x
            | m > 0 = x - m + 10
            | otherwise = x
            where
                m = x `mod` 10

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
# -*- coding:utf-8 -*-                                                                                     
import numpy as np
import scipy as sp

s = input()
n = len(s)
s_list = []

for i in range(0, n):
    if s[i] == 'B':
        if len(s_list) == 0:
            continue
        else:
            s_list.pop(-1)
    else:
        s_list.append(s[i])

S = ''
for i in range(0, len(s_list)):
    S = S + s_list[i]

print(S)



Measured memory_bytes: 12760
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()


Measured memory_bytes: 69740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

int main() {
  char c;
  stack<int> si;
  stack<pair<int, int>> sp;
  int i = 0, total = 0;
  while (scanf("%c", &c) != EOF) {
    if (c == '\\') si.push(i);

    if (c == '/' && !si.empty()) {
      int j = si.top(); si.pop();
      int a = i - j;
      total += a; 

      while (!sp.empty() && sp.top().first > j) {
        a += sp.top().second; sp.pop();
      }

      sp.push(make_pair(j, a));
    }

    i++;
  }

  cout << total << endl;
  
  vi suml;
  while (!sp.empty()) {
    suml.push_back(sp.top().second);
    sp.pop();
  }
  reverse(suml.begin(), suml.end());

  cout << suml.size();

  for (auto l: suml) {
    cout << " " << l;
  }
  cout << endl;
}



Measured memory_bytes: 3312
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

// use std::cmp::{max, min};

fn count_divisor(n: &u32) -> usize {
  (1..n + 1).filter(|i| n % i == 0).count()
}

fn main() {
  let n = read::<u32>();
  let mut count = 0;

  let ans = (1..n + 1)
    .filter(|x| x % 2 == 1)
    .filter(|x| count_divisor(x) == 8)
    .count();

  println!("{}", ans);
}

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

const int oo {1000000010};

int solve(const vector<int> xs){
  //Inicializa o vetor order com os números 0,1,2,3,4
  vector<int> order(5);
  iota(order.begin(), order.end(), 0);

  int ans = oo;
  //cout<<ans<<endl;

  do{
    int t = 0;

    //Avalia cada uma das permutações possíveis
    for(int i = 0; i < 4; ++i)
      t += 10 * ((xs[order[i]] + 9)/10);

    t += xs[order.back()];

    ans = min(ans, t);

    //segue para a próxima permutação
  }while(next_permutation(order.begin(), order.end()));

  return ans;
}

int main(){
  vector<int> xs(5);

  for(int i = 0; i < 5; ++i)
    cin>>xs[i];

  auto ans = solve(xs);

  cout<<ans<<'\n';

  return 0;
}

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

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int q;


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

    cin >> q;

    REP(_, q) {

        string A, B;
        vector<vector<int>> dp(1010, vector<int>(1010));

        cin >> A >> B;

        for (int i = 0; i < A.size(); i++) {
            if (A[i] == B[0]) dp[i][0] = 1;
            chmax(dp[i+1][0], dp[i][0]);
        }
        for (int i = 0; i < B.size(); i++) {
            if (A[0] == B[i]) dp[0][i] = 1;
            chmax(dp[0][i + 1], dp[0][i]);
        }
        
        for (int i = 1; i < A.size(); i++) {
            for (int j = 1; j < B.size(); j++) {
                if (A[i] == B[j]) {
                    chmax(dp[i][j], dp[i - 1][j - 1] + 1);
                } else {
                    chmax(dp[i][j], dp[i][j-1]);
                    chmax(dp[i][j], dp[i-1][j]);
                }
            }
        }



        cout << dp[A.size() - 1][B.size() - 1] << endl;


    }


    

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

void factor(map<ll, ll> &f, ll n) {
    ll temp = n;
    if(n == 1) {
        f[1] = 1;
        return;
    }
    for(ll i = 2;i * i <= n;i++) {
        while(temp % i == 0) {
            f[i]++;
            temp /= i;
        }
    }
    if(temp > 1) f[temp]++;
}

int main(void) {
    ll X;
    cin >> X;
    ll maxi = 1;
    repi2(i, 1, X) {
        ll gcd = 0;
        map<ll, ll> m;
        factor(m, i);
        iter(j, m) {
            if(gcd == 0) gcd = j.second;
            else gcd = __gcd(gcd, j.second);
        }
        if(gcd > 1) maxi = i;
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3640
k,a,b=map(int,input().split())
if b-a<=2:
  print(k+1)
else:
  p=k+1-a
  if p<=0:
    print(k+1)
  elif p%2==0:
    print(p*(b-a)//2+a)
  else:
    print((p-1)*(b-a)//2+a+1)

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

int main(void){
    int r, g, b;
    std::cin >> r >> g >> b;

    if((100*r+10*g+b)%4==0){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	replace(s.begin(),s.end(),',',' ');
	cout << s << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

int inf=1001001001;

vector<int> ve[2];

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> v;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        int ans=0;
        rep(j,b){
            int c;
            cin>>c; c--;
            ans|=(1<<c);
        }
        //cout<<ans<<endl;
        v.emplace_back(a,ans);
    }
    
    vector<int> dp(1<<n,inf);
    dp[0]=0;
    //配るDP
    rep(s,1<<n){
        rep(j,m){
            int t=s|v[j].second;
            dp[t]=min(dp[t],dp[s]+v[j].first);
        }
    }
    
    if (dp[(1<<n)-1]==inf) {
        cout<<-1<<endl;
      return 0;
    }
    cout<<dp[(1<<n)-1];
    
    
    
    return 0;
    
    
    vector<vector<int>> dp2(m+1,vector<int>(1<<n,inf));
    dp2[0][0]=0;
    rep(i,m){
        rep(s,1<<n){
            if (dp2[i][s]!=inf){
                int t2=s|v[i].second;
                int cost=v[i].first;
                dp2[i+1][t2]=min(dp2[i+1][t2],dp2[i][s]+cost);
                dp2[i+1][s]=min(dp2[i+1][s],dp2[i][s]);
            }
        }
    }
    
    
    cout<<dp2[m][(1<<n)-1]<<endl;
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin >>n;
	cout<<3*n*n;
	
return 0;
}



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

int main() {
  long X, Y, A, B, C;
  cin >>X >>Y >>A >>B >>C;
  
  vector<int> p(A), q(B), r(C);
  
  for (int i=0; i<A; i++){
    cin >>p[i];
  }
  for (int i=0; i<B; i++){
    cin >>q[i];
  }for (int i=0; i<C; i++){
    cin >>r[i];
  }
  
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  sort(r.rbegin(),r.rend());
  
  vector<long> ans(X+Y+C);
  int cnt=0;
  
  for (int i=0; i<X; i++){
    ans[cnt] = p[i];
    cnt++;
    //cout <<"red:"<<red[i] <<" ";
  }
  
  for (int i=0; i<Y; i++){
    ans[cnt] = q[i];
    cnt++;
    //cout <<" green:"<<green[i] <<" ";
  }
  
  for (int i=0; i<C; i++){
    ans[cnt] = r[i];
    cnt ++;
  }
  
  sort(ans.rbegin(),ans.rend());
  //cout <<endl;
  long an=0;
  
  for (int i=0; i<X+Y; i++){
    an += ans[i];
    //cout << "ans:" <<ans[i]<<endl;
  }
  
  cout <<an <<endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<int> stones;
    vector<int> energyReq;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int h;
        cin >> h;
        stones.push_back(h);
    }
    energyReq.push_back(0);
    energyReq.push_back(abs(stones[1] - stones[0]));
    for (int i = 2; i < n; i++){
        energyReq.push_back(min(energyReq[i - 2] + abs(stones[i] - stones[i - 2]), energyReq[i - 1] + abs(stones[i] - stones[i - 1])));
    }
    cout << energyReq.at(n - 1) << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
const int H = 10, W = 10;
int h, w, k, tot = 0, sumh[H], sumw[W],Map[H][W];
bool Check(int x, int y) {
    int sum = 0;
    for(int i = 0; i < h; ++i)
        if(x&(1<<i)) {
            sum += sumh[i];
        }
    for(int j = 0; j < w; ++j)
        if(y&(1<<j)) {
            sum += sumw[j];
        }
    
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j)
            if((x&(1<<i)) && (y&(1<<j)) && Map[i][j])
                --sum;
    }

    if(sum == tot - k) {
        //printf("%d %d %d\n",x,y,sum);
        return true;
    }
    return false;
}
int main() {
    int cnt = 0;
    string s;
    cin >> h >> w >> k;

    for(int i = 0; i < h; ++i) {
        cin >> s;
        for(int j = 0; j < w; ++j)
            if(s[j] == '#') ++tot, Map[i][j] = 1, ++sumh[i], ++sumw[j];
    }


    for(int i = 0; i <= (1<<h)-1; ++i) {
        for(int j = 0; j <= (1<<w)-1; ++j)
            if(Check(i,j)) ++cnt;
    }
    cout << cnt << endl;
return 0;
}

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

int main()
{
    int n;
    int i;
    cin>>n;
    int array[n];
    int dp[n];
    for(i=0;i<n;i++)
    {
        cin>>array[i];
    }
    dp[0] = 0;
    dp[1] = abs(array[1] - array[0]); 
    for(i=2;i<n;i++)
    {
        int diff1 = abs(array[i] - array[i-1]);
        int diff2 = abs(array[i] - array[i-2]);
        dp[i] = min(dp[i-1]+diff1, dp[i-2]+diff2);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[100009];
int N;

ll calc(int s){
    ll res=0,sum=s;
    rep1(i,N-1){
        if(sum>0){
            sum+=nums[i];
            if(sum>=0){
                res+=abs(sum+1);
                sum=-1;
            }
        }else{
            sum+=nums[i];
            if(sum<=0){
                res+=abs(sum-1);
                sum=1;
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin>>N;
    
    rep(i,N) cin>>nums[i];
    
    ll ans=LLINF;
    if(nums[0]==0){
        ans=min(ans,calc(1)+1);
        ans=min(ans,calc(-1)+1);
    }
    if(nums[0]>0){
        ans=min(ans,calc(nums[0]));
        ans=min(ans,calc(-1)+nums[0]+1);
    }
    if(nums[0]<0){
        ans=min(ans,calc(nums[0]));
        ans=min(ans,calc(1)-nums[0]+1);
    }
    
    cout1(ans)
}

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

int main()
{
    int h, w;
    long long ans = 0;
    cin >> h >> w;
    if (h == 1 || w == 1)
    {
        cout << "1\n";
        return 0;
    }
    if (h & 1)
    {
        --h;
        ans += (w + 1) / 2;
    }
    for (int i = 0; i < h / 2; i++)
    {
        ans += w;
    }
    cout << ans << endl;
    return 0;
}


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

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

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

    for (int i = n - 1; i >= 0; i--) {
        if (i != n - 1) {
            cout << " ";
        }
        cout << digits[i];
    }
    cout << endl;
}



Measured memory_bytes: 3100
package main

import "fmt"

func main() {
	var (
		n int32
		s string
	)
	fmt.Scan(&n, &s)
	for _, v := range s {
		x := v + n
		if x > 90 {
			x -= 26
		}
		fmt.Print(string(x))
	}
	fmt.Println()
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll  long long int
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    fast;
   
  
   ll n,l;
   cin>>n>>l;
   vector<string> v;
   string s;
   for(ll i=0;i<n;i++)
   {
    cin>>s;
    v.push_back(s);

   }
   sort(v.begin(),v.end());
   for(ll i=0;i<n;i++)
    cout<<v[i];
cout<<"\n";


}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; 
        x=(x*x)%p;
    }
    return res;
}
void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */

/* -------------------------------------- */
int main() {
	boost();
	int n,k;cin>>n>>k;
	ll dp[2010][2010];
	for (int i = 0; i <= 2000; i ++) {
    for (int j = 0; j <= 2000; j ++) dp[i][j] = 0;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= 2000; i ++) {
    for (int j = 0; j <= i; j ++) {
      if (j == 0) dp[i][j] = dp[i - 1][j];
      else if (j == i) dp[i][j] = dp[i - 1][j - 1];
      else dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % MOD;
    }
  }
	
	for(int i=1;i<=k;i++){
		ll ans = ((dp[n-k+1][i]%MOD)*(dp[k-1][i-1]%MOD))%MOD;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s;
    cin >> s;
    ll n = s.size(), sum = 0;
    for(int i = 0; i < (1<<(n - 1)); i++){
        vll a(n, 0);
        a[n - 1] = 1;
        REP(j, n - 1){
            if((i>>j) & 1){
                a[j] = 1;
            }
        }
        ll res = 0, dig;
        REP(j, n){
            if(a[j]){
                dig = j - res + 1;
                vll tmp;
                REP(k, dig){
                    tmp.push_back(s[res + k] - '0');
                    if(k){
                        REP(l, tmp.size() - 1) tmp[l] *= 10;
                    }
                }
                REP(k, dig) sum += tmp[k];
                res = j + 1;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

S = list(map(int, readline().strip()))
N = len(S)
MOD = 998244353
dp = [[0]*(2*N+1) for _ in range(2*N+1)]
dp[0][0] = 1

B = [0]*(N+1)
for i in range(N):
    B[i+1] = B[i] + S[i]
B.extend([B[-1] for _ in range(N)])
R = [0] + [2*i - B[i] for i in range(1, N+1)]
R.extend([R[-1] for _ in range(N)])

for i in range(2*N):
    for j in range(2*N+1):
        if not dp[i][j]:
            continue
        
        b = B[i+1] - j
        r = R[i+1] - (i - j)
        if b > 0:
            dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j])%MOD
        if r > 0:
            dp[i+1][j] = (dp[i+1][j] + dp[i][j])%MOD
print(dp[2*N][sum(S)])

Measured memory_bytes: 165724
from sys import exit
# A, B, C = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
# L = len(S)
# T = str(input())
# exit()
tmp = 0
for s in S:
    if tmp == s:
        print("Bad")
        exit()
    tmp = s
print("Good")


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<ll> t(n + 1), a(n + 1);
	for (int i = 1; i <= n; i++) cin >> t[i] >> a[i];

	ll anst = t[1], ansa = a[1];
	for (int i = 2; i <= n; i++) {
		ll x = anst, y = ansa;

		anst = max((x + (t[i] - 1)) / t[i], (y + (a[i] - 1)) / a[i]) * t[i];
		ansa = max((x + (t[i] - 1)) / t[i], (y + (a[i] - 1)) / a[i]) * a[i];
	}
	cout << anst + ansa << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N>>S;
    mat dp(N,vec(N,0));
    ll mod = (1e+9)+7;
    rep(j,N) dp[0][j] = j+1;
    reps(i,1,N-1){
        ll N_i = N-i;
        bool flag = S.at(i)==S.at(i-1);
        rep(j,N_i){
            if(j != 0) dp.at(i).at(j) = dp.at(i).at(j-1);
            if(flag) (dp.at(i).at(j) += dp.at(i-1).at(N_i)-dp.at(i-1).at(j))%=mod;
            else (dp.at(i).at(j) += dp.at(i-1).at(N_i)-dp.at(i-1).at(N_i-j-1))%=mod;
        }
    }
    ll ans =dp.at(N-2).at(1)-dp.at(N-2).at(0);
    (ans += mod)%=mod;
    cout<<ans<<endl;
    /*rep(i,N){
        rep(j,N){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
}


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

using namespace std;

int ok[(int)(4e6+6)];
int arr[11][11];

int sqr(int x)
{
	return x*x;
}

int main()
{
	for(int i=0;i<=2e3;i++)
		ok[i*i]=1;
	int n,d;
	cin >> n >> d;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
			cin >> arr[i][j];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int dis=0;
			for(int k=0;k<d;k++)
			{
				dis+=sqr(arr[i][k]-arr[j][k]);
			}
			ans+=ok[dis];
		}
	}
	cout << ans << endl;

}

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

int main()
{
	string str;
	long long n;
	long long res;
	cin >> str >> n;
	if(str.size() == 1){
		cout << n / 2 << endl;
		return 0;
	}else {
		int r = 0;
		int xx = str.size();
		for(int i = xx - 1; i > 0; i--){
			if(str[i] != str[i - 1]) {
				r = i;
				break;
			}
		}
//		cout << r << "egegererg\n";
		if(r == 0) cout << n * str.size() / 2 << endl;
		else{
			str = str + str;
			int lll = 1;
			int cnt = 0;
			for(int i = r; i < r + str.size() / 2 ; i++){
//				cout << str[i] << endl;
				if(str[i] == str[i + 1]) lll++;
				else{
//					cout << lll << endl;
					cnt = cnt + lll / 2;
					lll = 1;
				}
			}
			res = cnt * (n - 1);	
			lll = 1;
			cnt = 0;
//			cout << "r = " << r << endl;
			for(int i = 0; i < r ; i++){
				if(str[i] == str[i + 1]) lll++;
				else{
//					cout << lll << endl;
					cnt = cnt + lll / 2;
					lll = 1;
				}
			}
			res += cnt;
			res = res + (str.size() / 2 - r) / 2;
			cout << res << endl;
		}	
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1001;
const int M = 1e6 + 123;
const double pi = 3.14159265359;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int a[N];

void solve(){
    int n;
    cin >> n;
    ll ans = 1000;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++){
        while (i < n && a[i] >= a[i+1]){
            i++;
        }
        ll k = ans / a[i];
        ans -= k*a[i];
        while (i < n && a[i] <= a[i+1]){
            i++;
        }
        ans += k*a[i];
    }
    cout << ans;
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int n,a,b,h[100010];
bool check(int x)
{
	int res=0;
	for (int i=0;i<n;i++)
	{
		if (1LL*x*b>=1LL*h[i])
		{
			continue;
		}
		res+=(h[i]-x*b+a-1)/a;
		if (res>x)
		{
			return false;
		}
	}
	return true;
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	a-=b;
	for (int i=0;i<n;i++)
	{
		scanf("%d",&h[i]);
	}
	int l=1,r=1e9,mid;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (check(mid))
		{
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k, n;
    cin>>k>>n;
    int x=k*500;
    if(x>=n)
    {
		cout<<"Yes\n";
	}
	else cout<<"No\n";
}


Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int n, l;
    cin >> n >> l;

    int aji_sum = l * n + n * (n - 1) / 2;
    if (l < 0 && l + n - 1 >= 0)
        print(aji_sum);
    else if (l < 0)
        print(aji_sum - (l + n - 1));
    else print(aji_sum - l);

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define maxn 200010
#define N maxn / 26 + 10
char s[maxn];
int l[N], r[N];
int cnt[26];
int sum[maxn][26], nxt[maxn][26];
int n, m, sz, ans;
char find(int r, int l = 0) {
	for (int i = 0; i < 26; i++) if (!(sum[r][i] - sum[l][i])) return i + 97;
	return 20040826;
}
int main() {
	sz = sizeof cnt;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int num = 0; r[m = 1] = n;
	for (int i = n; i; i--) {
		memcpy(nxt[i], nxt[i + 1], sz);
		int x = s[i] - 'a';
		nxt[i][x] = i;
		num += cnt[x]++ == 0;
		if (num >= 26) {
			l[m] = i;
//			if (i != 1) 
			r[++m] = i - 1;
			memset(cnt, 0, sz);
			num = 0;
		}
	}
//	printf("%d\n", num);
	for (int i = 1; i <= n; i++) {
		memcpy(sum[i], sum[i - 1], sz);
		sum[i][s[i] - 'a']++;
	}
	putchar(ans = find(r[m]));
	for (int i = m - 1; i; i--) {
//		printf("%d\n", nxt[l[i]][ans - 'a']);
//		printf("%d\n", l[i]);
		putchar(ans = find(r[i], nxt[l[i]][ans - 'a']));
	}
	putchar(10);
	return 0;
}

Measured memory_bytes: 41088
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  string s,temp="keyence";
  cin>>s;
  int x=0,c=0,ans=0;
  while(x<7){
    if(s[x]==temp[x]){
      c++;
      x++;
    }
    else break;
  }
  x=0;
  if(c==0){
    rep(i,s.size()-7,s.size()){
      if(s[i]==temp[x]) c++;
      x++;
    }
    if(c==7) co("YES");
    else co("NO");
  }
  else{
    x=c;
    c=7-c;
    rep(i,s.size()-c,s.size()){
      if(s[i]==temp[x]) ans++;
      x++;
    }
    if(ans==c) co("YES");
    else co("NO");
  }
  
  return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = list(read())
if n % 2 == 1:
    print("No")
else:
    t1 = ""
    t2 = ""
    for i in range(n // 2):
        t1 += t[i]
        t2 += t[i + n // 2]
    if t1 == t2:
        print("Yes")
    else:
        print("No")



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

int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> p(n);
  rep(i,n){
    cin >> p[i].first >> p[i].second;
    swap(p[i].first, p[i].second);
  }
  sort(p.begin(),p.end());
  ll time = 0;
  rep(i,n){
    time += p[i].second;
    if(p[i].first < time){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 6412
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
string a[101];
int n,i,l;
int main(){
    scanf("%d%d",&n,&l);
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
        cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
#define pri 100000000007
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;

         
   



int main()
{    
 

   #ifdef APNA_IO
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
   #endif
          ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

    ll r;
    cin>>r;
    cout<<3*r*r<<endl;



}

Measured memory_bytes: 2560
import java.util.*;
import static java.lang.System.out;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().AOJ0055();
	}
	
	void AOJ0055(){	// Sequence
		while(sc.hasNext()){
			double last=sc.nextDouble(), ans=last;
			for(int i=2; i<=10; i++){
				ans+= i%2==0? last*2: last/3;
				last = i%2==0? last*2: last/3;
				// out.println(last);
			}
			out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll a, b;
	while (cin >> a >> b) {
		ll g = gcd(a, b);
		ll l = lcm(a, b);
		cout << g << " " << l << endl;
	}
	return 0;
}



Measured memory_bytes: 3000
#include <iostream>
using namespace std;
int main()
{
	int d,n;
	cin >> d >> n;
	if(n==100) n++;
	if(d==0){
		cout << n << endl;
		return 0;
	}
	if(d==1){
		cout << n*100 << endl;
		return 0;
	}
	if(d==2){
		cout << n*10000 << endl;
		return 0;
	}
	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char A[5];
    int a,b,c,d;
    scanf("%s",A);
    a=A[0]-48;
    b=A[1]-48;
    c=A[2]-48;
    d=A[3]-48;
    if(a+b+c+d==7)
        printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a+b+c-d==7)
        printf("%d+%d+%d-%d=7",a,b,c,d);
    else if(a+b-c+d==7)
        printf("%d+%d-%d+%d=7",a,b,c,d);
    else if(a+b-c-d==7)
        printf("%d+%d-%d-%d=7",a,b,c,d);
    else if(a-b+c+d==7)
        printf("%d-%d+%d+%d=7",a,b,c,d);
    else if(a-b+c-d==7)
        printf("%d-%d+%d-%d=7",a,b,c,d);
    else if(a-b-c+d==7)
        printf("%d-%d-%d+%d=7",a,b,c,d);
    else
        printf("%d-%d-%d-%d=7",a,b,c,d);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/c++io.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
 int x,y;
 cin>>x>>y;
if(x==y)
    cout<<"Draw"<<endl;
  else  if(x==1) cout<<"Alice"<<endl;
  else  if(y==1) cout<<"Bob"<<endl;
  else {
      if(x>y) cout<<"Alice"<<endl;
      else cout<<"Bob"<<endl;

      }

}

Measured memory_bytes: 3644
#
# abc053 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """149696127901"""
        output = """27217477801"""
        self.assertIO(input, output)


def resolve():
    x = int(input())
    ans = x//11 * 2
    if 1 <= x % 11 <= 6:
        ans += 1
    elif x % 11 >= 7:
        ans += 2
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16240