akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){cin >> v[i];}

    long long int result = 0;
    REP(i,n){
        while((v[i]%2)==0){
            result++;
            v[i] /= 2;
        }

    }

    cout << result << endl;

    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli a,b;

int main(){
  cin >> a >> b;
  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <cstdio>
int cnt[100001];
bool prime[100001];
int sum[100001];
int main(int argc, const char * argv[]) {
 
    prime[2] = true;
    for(int i=3;i<100000;i+=2){
        bool ok = true;
        for(int j=2;j*j<=i;j++){
            if(i%j==0){
                ok=false;
                break;
            }
        }
        if(ok) prime[i]=true;
    }
    
    
    for(int i=1;i<100000;i+=2){
        int j = (i+1)/2;
        if(prime[j]&&prime[i]) cnt[i]++;
    }
    
    for(int i=1;i<=100000;i++) sum[i] = sum[i-1]+cnt[i];
    

    int q;
    
    scanf("%d",&q);
    
    while(q--){
        
        int l,r;
        
        scanf("%d %d",&l,&r);
        
        printf("%d\n",sum[r]-sum[l-1]);
        
    }
    
    return 0;
}


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

using namespace std;

int main(){
    int n,l;
    cin>>n>>l;
    int s=0,ans=1000;
    for (int i = 1; i <= n; ++i) {
        if(abs(ans)>abs(l+i-1))ans=l+i-1;
        s+=l+i-1;
    }
    cout<<s-ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int n, l, ans = 0, tmp = INT_MAX;
    bool f = 0;

    cin >> n >> l;

    for (int i = 0; i < n; i++) {

        int z = l+i;
        ans+=z;

        if (tmp > abs(z)) {

            tmp = abs(z);
            if (z >= 0) f = 1;
            else f = 0;
        }
    }

    cout << (f ? ans-tmp : ans+tmp);

    return 0;
}


Measured memory_bytes: 256
from collections import *
H,W = map(int,input().split())
S = [input() for h in range(H)]
V = [W*[0] for h in range(H)]
V[0][0] = 1
Q = deque([(0,0)])
while Q:
  x,y = Q.popleft()
  for dx,dy in ((-1,0),(0,-1),(1,0),(0,1)):
    if 0<=x+dx<H and 0<=y+dy<W and V[x+dx][y+dy]==0 and S[x+dx][y+dy]==".":
      V[x+dx][y+dy] = V[x][y]+1
      Q.append((x+dx,y+dy))

if V[H-1][W-1]==0:
  print(-1)
else:
  print(H*W-sum(s.count("#") for s in S)-V[H-1][W-1])

Measured memory_bytes: 9484
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){ 
  int a,b; cin >> a >> b;
  if(a>=13){
    cout << b <<endl;
  }else if(a>=6 && a<13){
    cout << b/2 <<endl;;
  }else if(5>=a){
    cout << 0 << endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
  string s;
  cin >> s;
  int count=0;
  char a;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='1')count++;
    else{
      a = s.at(i);
      break;
    }
  }
  ll K;
  cin >> K;
  if(K<=count)cout << 1 << endl;
  else cout << a << endl;
}

Measured memory_bytes: 256
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]

def calc_score(day, contest, score, last):
  last[contest] = day + 1

  contest_score = s[day][contest]
  score += contest_score

  dis = 0
  for i in range(26):
    dis += c[i] * ((day + 1) - last[i])
  score -= dis

  return score


score = 0
last = [0 for i in range(26)]
for day in range(d):
  t_score = 0
  for each_contest in range(26):
    each_t_score = calc_score(day, each_contest, score, last)
    if each_t_score > t_score:
      t_score = each_t_score
      contest = each_contest

  score = t_score
  last[contest] = day + 1

  print(contest + 1)

Measured memory_bytes: 9356
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    set<string> used;
    cout << "?aaaaa" << endl;

    int i = 0;
    for(;;){
        string s;
        cin >> s;
        if(s[0] != 'a' || used.find(s) != used.end()){
            cout << "!OUT" << endl;
            return 0;
        }
        used.insert(s);

        s = s[s.size()-1];
        if(i == 26)
            s += "aa";
        else
            s += 'a' + i;
        s += 'a';
        ++ i;

        printf("?%s\n", s.c_str());
        fflush(stdout);
    }
}

Measured memory_bytes: 0
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let mut ans = true;

    let mut t_before = 0;
    let mut x_before = 0;
    let mut y_before = 0;

    for _ in 0..n {
        let (t_after, x_after, y_after): (i64, i64, i64) = get_triple();
        let pos_diff = (x_before - x_after).abs() + (y_before - y_after).abs();
        let t_diff = t_after - t_before;

        if pos_diff > t_diff { ans = false; }
        if t_diff % 2 != pos_diff % 2 { ans = false; }

        t_before = t_after;
        x_before = x_after;
        y_before = y_after;
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 1
const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int MAXVAL = (int) 1e6;

int cnt[MAXVAL + 1];
int s[MAXVAL + 1], s2[MAXVAL + 1];

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    int ans = 0;
    for(i = 0; i < n; i++) {
        int x;
        cin >> x;
        add(s[x], x);
        sub(ans, x);
    }

    for(i = 2; i <= MAXVAL; i++) {
        if(cnt[i] == 0) {
            for(j = i; j <= MAXVAL; j += i) {
                cnt[j]++;
            }
        }
    }

    for(i = MAXVAL; i >= 1; i--) {
        int cur = 0, sum = 0;
        for(j = i; j <= MAXVAL; j += i) {
            add(cur, s[j]);
            sub(sum, s2[j]);
        }

        mul(cur, cur);
        add(cur, sum);
        s2[i] = cur;
        add(ans, (1LL * s2[i] * lgput(i, MOD - 2)) % MOD);

    }
    mul(ans, lgput(2, MOD - 2));
    cout << ans;

    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

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

    bool ans = s[4] == s[5] && s[2] == s[3];

    cout << (ans? "Yes": "No") << endl;

    return 0;
}

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

using namespace std;

typedef long long int lli;

int n;
lli a[3002], inf = 1e+15;
vector<vector<vector<lli>>> dp(2, vector<vector<lli>>(3002, vector<lli>(3002, inf)));

lli rec(int turn, int l, int r, lli score) {
    if (r < l) return score;
    if (dp[turn][l][r] != inf) return score + dp[turn][l][r];

    lli coef = (turn) ? -1 : 1;
    lli L = rec(!turn, l+1, r, score+coef*a[l]);
    lli R = rec(!turn, l, r-1, score+coef*a[r]);
    
    if (turn==0)    dp[turn][l][r] = (L>R) ? L-score : R-score;
    else            dp[turn][l][r] = (L>R) ? R-score : L-score;

    return score + dp[turn][l][r];
}

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

    cin >> n;
    for (int i=0; i<n; i++) cin >> a[i+1];

    cout << rec(0, 1, n, 0) << endl;

    return 0;
}


Measured memory_bytes: 212096
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = S()
    t = S()
    ansa = []
    anslis = []
    lisans = []
    for i in range(len(s)):
        for j in range(len(t)):
            if 0 <= i + j < len(s) and (s[i + j] == t[j] or s[i + j] == "?"):
                continue
            break
        else:
            ansa.append((i, i + j))
    if len(ansa) == 0:
        print("UNRESTORABLE")
        return
    for ans in ansa:
        a = ""
        for num in range(len(s)):
            i = s[num]
            if ans[0] <= num <= ans[1]:
                i = t[num-ans[0]]
            a += i
        anslis.append(a)
    for ans in anslis:
        k = ""
        for i in ans:
            if i == "?":
                k += "a"
            else:
                k += i
        lisans.append(k)
    lisans.sort()
    print(lisans[0])
        
    return

# D
# 解説AC
# なんていうか脳みそが足りない
# 制限速度に落とし込むのはわかったけど。。。
# 一つの制限速度にに対して
# 0<=x<=l なら v+(l-x) 
# l<=x<=r なら v 
# r<=x<=T なら v+(x-r)
# つらい

def D():
    n = II()
    t = LI()
    v = LI()
    t += [0]
    v = [0] + v + [0]
    time = [[0, 0]]
    for i in range(1, n+2):
        time.append((time[-1][1], time[-1][1] + t[i - 1]))
    def vx(x):
        res = inf
        for i in range(n+2):
            res = min(res, f(i, x))
        return res
    def f(i, x):
        l, r = time[i]
        vi = v[i]
        return vi + (l - x) if 0 <= x <= l else vi if l <= x <= r else vi + (x - r)
    ans = 0
    for x in range(sum(t) * 2):
        ans += 0.25 * (vx(x/2) + vx(x/2 + 0.5))
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()




Measured memory_bytes: 47336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく

const int MAX = 100100;
const int MOD = 1000000007;

ll powmod(ll x, ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }
        else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}
int main(){
    int n; cin >> n;
    ll a[n];
    map<ll,ll> mp;
    rep(i,n){
        cin >> a[i];
        ll ai=a[i];
        for(int j=2;j*j<=ai;j++){
            if(ai%j==0){
                ll res=0;
                while(ai%j==0){
                    res++;
                    ai/=j;
                }
                chmax(mp[j],res);
            }
        }
        if(ai>1) chmax(mp[ai],1LL);
    }
    ll l=1;
    for(auto p:mp){
        l*=powmod(p.fi,p.se);
        l%=MOD;
    }
    ll ans=0;
    rep(i,n){
        ans+=l*powmod(a[i],MOD-2)%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
from itertools import combinations
from collections import defaultdict
n = int(input())

d = defaultdict(int)

for i in range(n):
    d[input()[0]] += 1

w = ['M', 'A', 'R', 'C', 'H']

counter = 0
for w in combinations(w, 3):
    counter += d[w[0]] * d[w[1]] * d[w[2]]

print(counter)

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

using namespace std;
int N, K;
string P[10000];
int alp[26];

int solve(){
   int ret=0;
   while(1){
      sort(alp, alp+26);
      reverse(alp, alp+26);

      if(alp[K-1]==0) return ret;
      for(int i=0; i<K; i++) alp[i]--;
      ret++;
   }
}

int main(){

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

   for(string s: P){
      alp[s[0]-'A']++;
   }


   cout<< solve()<< endl;

   return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <map>
#include <math.h>
#include <set>
#include <vector>
#define ll long long
const int INF = 0x3f3f3f3f;
const int NINF = -INF - 1;
const int mod=1e9+7;
const int N=1e5+5;
using namespace std;
int a[4];
int vis[4];
int vi[4][10];
int main()
{
    int n,m,x,y;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        if(x==1&&y==0&&n!=1) {printf("-1\n");return 0;}
        if(!vis[x])
        {
         vis[x]=1;vi[x][y]=1;a[x]=y;
        }
        else
        {
            if(vi[x][y]==1) a[x]=y;
            else {printf("-1\n");return 0;}
        }
    }
    if(a[1]==0&&n!=1) a[1]=1;
    for(int i=1;i<=n;i++) printf("%d",a[i]);
    printf("\n");
    return 0;
}//cmaidmai

Measured memory_bytes: 256
"use strict";

function main(input) {
  input = input.trim().split("");
  let ans = 0;
  for (let i = 0; i < Math.floor(input.length / 2); i++) {
    if (input[i] !== input[input.length - (i + 1)]) {
      ans++;
    }
  }
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

int main(){
    ll x;
    cin >> x;

    ll k = 100;
    ll ans = 0;

    while(1){
        if(k >= x){
            break;
        }

        k *= 1.01;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
// URL: https://atcoder.jp/contests/abc173/tasks/abc173_b

import std.algorithm, std.array, std.bitmanip, std.container, std.conv, std.format,
       std.functional, std.math, std.range, std.traits, std.typecons, std.stdio, std.string;

version(unittest) {} else
void main()
{
  int N; io.getV(N);
  string[] S; io.getC(N, S);

  foreach (key; ["AC", "WA", "TLE", "RE"]) {
    io.put(key, "x", S.count(key));
  }
}

auto io = IO!()();
import std.stdio;
struct IO(alias IN = stdin, alias OUT = stdout)
{
  import std.meta : allSatisfy;
  import core.stdc.stdlib : exit;

  void getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }
  void getA(T)(size_t n, ref T v)
    if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }
  void getC(T...)(size_t n, ref T v)
    if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v) w = new typeof(w)(n);
    foreach (i; 0..n) foreach (ref w; v) get(w[i]);
  }
  void getM(T)(size_t r, size_t c, ref T v)
    if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }
  template getS(E...)
  {
    void getS(T)(size_t n, ref T v)
    {
      v = new T(n);
      foreach (ref w; v) foreach (e; E) mixin("get(w."~e~");");
    }
  }

  const struct PutConf
  {
    bool newline = true, flush, exit;
    string floatFormat = "%.10f", delimiter = " ";
  }

  void put(alias conf = "{}", T...)(T v)
  {
    mixin("const PutConf c = "~conf~"; putMain!c(v);");
  }
  void putB(alias conf = "{}", S, T)(bool c, S t, T f)
  {
    if (c) put!conf(t);
    else put!conf(f);
  }
  void putRaw(T...)(T v)
  {
    OUT.write(v);
    OUT.writeln;
  }

  private
  {
    dchar[] buf;
    auto sp = (new dchar[](0)).splitter;

    void nextLine()
    {
      IN.readln(buf);
      sp = buf.splitter;
    }
    void get(T)(ref T v)
    {
      if (sp.empty) nextLine();
      v = sp.front.to!T;
      sp.popFront();
    }

    void putMain(PutConf c, T...)(T v)
    {
      foreach (i, w; v) {
        putOne!c(w);
        if (i+1 < v.length) OUT.write(c.delimiter);
      }
      static if (c.newline) OUT.writeln;
      static if (c.flush) OUT.flush();
      static if (c.exit) exit(0);
    }
    void putOne(PutConf c, T)(T v)
    {
      static if (isInputRange!T && !isSomeString!T) putRange!c(v);
      else static if (isFloatingPoint!T) OUT.write(format(c.floatFormat, v));
      else static if (hasMember!(T, "fprint")) v.fprint(OUT);
      else OUT.write(v);
    }
    void putRange(PutConf c, T)(T v)
    {
      auto w = v;
      while (!w.empty) {
        putOne!c(w.front); w.popFront();
        if (!w.empty) OUT.write(c.delimiter);
      }
    }
  }
}


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

string S;
ll K;

ll count(ll i) {
    size_t j = 1;
    for (; j < S.size(); j++) {
        if (S[j+i] != S[i]) break;
    }
    return j;
}

int main(void)
{
    cin >> S;
    cin >> K;

    vector<ll> counts;
    for (size_t i = 0; i < S.size();) {
        ll d = count(i);
        counts.push_back(d);
        i += d;
    }

    ll count = 0;
    if (S[0] == S[S.size()-1]) {
        if (counts.size() == 1) {
            count = counts[0] * K / 2;
        } else {
            count =
                counts[0] / 2 
                + counts[counts.size()-1] / 2
                + (counts[counts.size()-1] + counts[0]) / 2 * (K-1);
            for (size_t i = 1; i < counts.size()-1; i++) {
                count += counts[i] / 2 * K;
            }
        }
    } else {
        for (size_t i = 0; i < counts.size(); i++) {
            count += counts[i] / 2 * K;
        }
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
cnt = 0
n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
    m = i
    for j in range(i, n):
        if lst[j] < lst[m]:
            m = j
    if m != i:
        lst[i], lst[m] = lst[m], lst[i]
        cnt += 1
print(*lst)
print(cnt)

Measured memory_bytes: 7680
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll K;string S;cin>>K>>S;
    ll N=S.size();
    if(N<=K)cout<<S<<"\n";
    else {
        REP(i,K)cout<<S[i];
        cout<<"...\n";
    }
}

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;
 
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")
}
 
#[allow(non_snake_case, unused_variables)]
fn main() {
    let S: String = read();
    let ans = &S[0..S.len()-8].to_string();
    println!("{}", ans);
}



Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] d = new int[n];

        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }

        Arrays.sort(d);
        int cnt = 1;
        for (int i = 1; i < n; i++) {
            if (d[i-1] != d[i])
                cnt++;
        }

        System.out.println(cnt);
    }
}



Measured memory_bytes: 21844
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

// -----------------------------------------------------------------------------

const int N = 2e5 + 5;
int n;
int a[N], f[N];

inline ll choose_two(ll n) {
    return n * (n - 1) / 2;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++f[a[i]];
    }
    ll su = 0;
    for (int i = 1; i <= n; ++i) {
        su += choose_two(f[i]);
    }
    for (int i = 0; i < n; ++i) {
        cout << su - f[a[i]] + 1 << '\n';
    }
}

// -----------------------------------------------------------------------------

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    // preprocess();
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}


Measured memory_bytes: 3712
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np
import collections

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = int_mtx(Q)

c = collections.Counter(A)

ans = sum(A)

for i in range(0,Q):
    Bi = BC[i,0]
    Ci = BC[i,1]
    ans = ans-c[Bi]*Bi + c[Bi]*Ci
    print(ans)
    if Ci in c:
        c[Ci] = c[Ci] + c[Bi]
        del c[Bi]
    else:
        c[Ci] = c[Bi]
        del c[Bi]



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

struct Dinic {
#define Vmax 202
    int s,t,level[Vmax],cup[Vmax][Vmax];
    bool keep_out[Vmax];
    vector<int> v[Vmax];
    stack<int> st;
    int max_flow() {
        int flow = 0,tmp;
        while(bfs()) do {
            int now = s;
            tmp = dfs(s);
            flow += tmp;
            while(!st.empty()) {
                cup[now][st.top()] -= tmp;
                cup[st.top()][now] += tmp;
                now = st.top();
                st.pop();
            }
        } while(tmp);
        return flow;
    }
    bool bfs() {
        queue<pair<int,int>> que;
        rep(i,Vmax) keep_out[i] = false;
        rep(i,Vmax) if (i^t) level[i] = INF;
        rep(i,v[t].size()) if (cup[v[t][i]][t] > 0) que.push(mp(v[t][i], 1));
        while(!que.empty()) {
            int a = que.front().fi, c = que.front().se;que.pop();
            if (level[a] <= c || level[s] < c) continue;
            level[a] = c;
            rep(i,v[a].size()) if (cup[v[a][i]][a] > 0) que.push(mp(v[a][i], c+1));
        }
        if (level[s] == INF) return false;
        else return true;
    }
    int dfs(int a) {
        rep(i,v[a].size()) {
            if (level[a] > level[v[a][i]] && cup[a][v[a][i]] > 0 && !keep_out[v[a][i]]) {
                if (v[a][i] == t) {st.push(t);return cup[a][t];}
                int tmp = dfs(v[a][i]);
                if (tmp) {st.push(v[a][i]);return min(tmp, cup[a][v[a][i]]);}
            }
        }
        keep_out[a] = true;
        return 0;
    }
    //array[Vmax][Vmax] exists!
    //　　-> int cup[Vmax][Vmax] -> map<int,int> cup[Vmax]
};

int n,a,sum;
Dinic D;

signed main() {
    cin >> n;
    D.s = 0, D.t = n+1;
    rep1(i,n) {
        cin >> a;
        if (a > 0) {
            sum += a;
            D.v[i].pb(n+1);
            D.v[n+1].pb(i);
            D.cup[i][n+1] = a;
        }
        if (a < 0) {
            D.v[0].pb(i);
            D.v[i].pb(0);
            D.cup[0][i] = -a;
        }
        for (int j=2;i*j<=n;j++) {
            D.v[i].pb(i*j);
            D.v[i*j].pb(i);
            D.cup[i][i*j] = INF/10;
        }
    }
    cout << sum - D.max_flow() << endl;
}





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

int_fast64_t n, a[100001], l, r, mid, x, i, t1, t2;

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

        l = 0;
        r = 1e18;
        while(r-l>1){
                mid = x = (r-l)/2+l;
                for(i=0; i<n; i++) x -= x%a[i];
                if(x<=2) l = mid;
                else r = mid;
        }
        t1 = l;

        l = -1;
        r = 1e18;
        while(r-l>1){
                mid = x = (r-l)/2+l;
                for(i=0; i<n; i++) x -= x%a[i];
                if(x<2) l = mid;
                else r = mid;
        }
        t2 = r;

        if(t1<t2) puts("-1");
        else printf("%ld %ld\n", t2, t1);

        return 0;
}


Measured memory_bytes: 1024
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LOOP1(n) for(int i=0;i<n;i++)
#define LOOP2(n) for(int j=0;j<n;j++)
#define LOOP3(n) for(int k=0;k<n;k++)
#define Psi pair<string,int>
#define Pis pair<int,string>
#define Pii pair<int,int>
// ??????????????????memset(a,0,sizeof(a));
// ?´???°?????? if(x<2)return0;else if(x==2)return1;if(x%2==0)return0;for(i=3;i*i<=x;i+=2){if(x%i==0)return0;}return1;}p440
//vector size();push_back(x);pop_back();begin();end();insert(p,x);erase(p);clear();
//stack  size();top();pop();push(x);emtpy();
//queue  size();front();pop();push(x);empty();
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 1;
static const int GRAY = 2;
static const int BLACK = 3;
int n; int M[MAX][MAX];
int color[MAX]; int d[MAX]; int p[MAX];
int main(){
	int u, k, v, c, uu, sum = 0;
	cin >> n;
	LOOP1(n){
		LOOP2(n){
			M[i][j] = INFTY;
		}
	}
	LOOP1(n){
		cin >> u >> k;
		LOOP2(k){
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	for (int i = 0; i < n; i++){
		color[i] = WHITE;
		d[i] = INFTY;
		p[i] = -1;
	}
	d[0] = 0;
	while (true){
		int mincost = INFTY;
		LOOP1(n){
			if (color[i] != BLACK && mincost > d[i]){
				mincost = d[i];
				uu = i;
			}
		}
		if (mincost == INFTY) break;
		color[uu] = BLACK;
		LOOP1(n){
			if (M[uu][i] != INFTY && color[i] != BLACK){
				if (M[uu][i] + d[uu] < d[i]){
					d[i] = d[uu] + M[uu][i];
					color[i] = GRAY;
					p[i] = u;
				}
			}
		}
	}
	LOOP1(n){
		cout << i << ' ' << d[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
a, b, c, d = list(map(int, input().split()))
def overlap(a, b):
    if max(a[0], b[0]) > min(a[1], b[1]):
        return [0, 0]
    return [max(a[0], b[0]), min(a[1], b[1])]
ans = overlap([a, b], [c, d])
print(ans[1] - ans[0])

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		HashMap<Integer, Integer> ball = new HashMap<Integer,Integer>();
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt();
			if(ball.containsKey(a)) {
				ball.replace(a, ball.get(a)+1);
			}else {
				ball.put(a, 1);
			}
		}
		ArrayList<SSS> set = new ArrayList<SSS>();
		for(int a:ball.keySet()) {
			set.add(new SSS(a,ball.get(a)));
		}
		SSS[] a = new SSS[set.size()];
		Arrays.sort(set.toArray(a));
		int ans = 0;
		for(int i = 0;i < a.length - K;i++) {
			ans += a[i].getNum();
		}
		System.out.println(ans);
	}

}
class SSS implements Comparable<SSS>{
	int num;
	int seed;
	SSS(int seed,int num){
		this.seed = seed;
		this.num = num;
	}

	int getNum() {
		return this.num;
	}

	@Override
	public int compareTo(SSS o) {
		if(this.getNum() > o.getNum())return 1;
		if(this.getNum() < o.getNum())return -1;
		return 0;
	}
}


Measured memory_bytes: 100944
N=int(input())
tt = xx = yy = 0

for i in range(N):
    t, x, y = map(int,input().split())
    dif = abs(x-xx) + abs(y - yy)
    if dif > t - tt:
        print("No")
        quit();
    else:
        if (t-tt-dif)%2 != 0:
            print("No")
            quit()
    tt = t
    xx = x
    yy = y

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll g, s;
  cin >> g >> s;
  // ll n, m, k;
  // cin >> n >> m >> k;
  fi(0, g + 1)
    fj(0, g + 1) {
      if(i + j <= s && i + j + g >= s)
        ans++;
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const auto INF =(long long)1e7;
using ull =unsigned long long;
using v = vector<ull>;
ull gcd(ull a,ull b){
  return b==0 ? a : gcd(b,a%b);
}

ull lcm(ull a,ull b){
  ull ans = a/gcd(a,b);
  return b%ans==0?b:ans*b;
}

template<typename ITE>
ull lcmr(ITE begin,ITE end){
   accumulate(begin,end,1,lcm);
}

int main()
{
  int n;
  cin >> n;
  auto t = v(n,0);
  for (int i = 0; i < n; i++)
  {
    cin >> t[i];
  }
  ull ans = 1;
  for (int i = 0; i < n; i++)
  {
    ans = lcm(ans,t[i]);
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    xs = iterate ((`mod` k) . (7 +) . (10 *)) (7 `mod` k) :: [Int]
  print $ if k `mod` 2 == 0 || k `mod` 5 == 0 then -1 else succ . length . takeWhile (/= 0) $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;
long long C[2002][2002];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    for(int i=0;i<2001;i++)
        C[i][0]=1;
    for(int i=1;i<2001;i++)
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
        cout<<(C[k-1][i-1]*C[n-k+1][i])%MOD<<"\n";
    return 0;
}


Measured memory_bytes: 26212
A,B,C = map(int,input().split())
X = list(map(int,input().split()))
now = 0
for i in range(A):
    Y = list(map(int,input().split()))
    ans = C
    for j in range(B):
        ans += Y[j]*X[j]
    if (ans)>0:
        now += 1
print(now)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    string s1, s2, s3;
    io.read(s1, s2, s3);
    map<char, char> mp;
    for(char i = 'a', j = 'A'; i <= 'z'; i++, j++){
        mp[i] = j;
    }
    string ans = {mp[s1[0]], mp[s2[0]], mp[s3[0]]};
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
ll a[100000+1];
ll n,k;
int dp[1000050][3];
int solve(int start,int turn){
   if(start==k)
    return 1;
   else if(start>k)
    return 0;
  if(dp[start][k]!=-1)
  {//cout<<"yes"<<endl;
  return dp[start][k];
  }
  int ans=0;
   for(int i=0;i<n;i++){
    ans=(ans|solve(start+a[i],turn^1));
   }
   return dp[start][k]=ans^1;
}
int main(){
    IOS;   
   cin>>n>>k;
   memset(dp,-1,sizeof dp);
   loop(n)cin>>a[i];
   int ans=solve(0,0);
   //cout<<ans<<endl;
   if(ans==0)
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
}
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 
//csjosh

Measured memory_bytes: 17280
#include<iostream>
using namespace std;
int main(){
int a,b;
for (int h = 0;; h++){
cin >> a >> b;
if (a != 0){
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++){
if (j > 0 && j < b - 1 && i>0 && i<a-1){
cout << "." ;
}
else{
cout << "#" ;
}
if(j==b-1){
cout<<endl;
}
}
}
cout<<endl;
}
else{
break;
}
}
return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];
ll dp[1001][1001];
char a[1001][1001];

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

	ll h,w;
	cin>>h>>w;

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1 && j==1){
				dp[i][j] = 1;
			}
			else if(a[i][j] == '.')
				dp[i][j] = add(dp[i-1][j], dp[i][j-1]);
			else
				dp[i][j] = 0;
		}
	}
	cout<<dp[h][w]%mod;
	return 0;
}


Measured memory_bytes: 9088
if __name__ == "__main__":
    N, M = map(int, input().split())
    H = list(map(int, input().rstrip().split(' ')))
    nodes = [[] for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        nodes[a-1].append(b-1)
        nodes[b-1].append(a-1)
    #print(nodes)
    ans = 0
    for i, children in enumerate(nodes):
        h = H[i]
        result = 1
        for c in children:
            h_ = H[c]
            if h <= h_:
                result = 0
                break
        ans += result
    print(ans)

        


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

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

  string n;
  cin >> n;
  int size=(int)n.size();
  ll sum=0;
  rep(i, size){
    int m=n[i]-'0';
    sum+=m;
  }
  if(sum%9==0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll Ans,Max,x,n;
int main(){
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>x;
		Ans+=x;
		Max=max(Max,x);
	}
	Max/=2;
	Ans-=Max;
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

void solve()
{
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for (int i=0; i<n; i++) {
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	for (int i=0; i<k; i++) {
		ans += a[i];
	}
	cout << ans << "\n";
}

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

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
  int m, n;
  int a[100][100] = {0}, b[100] = {0}, c[100] = {0};
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; ++j) {
    cin >> b[j];
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      c[i] += a[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; ++i) {
    cout << c[i] << endl;
  }
  return 0;
} 



Measured memory_bytes: 3140
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  ll N;
  cin >> N;
  vector<ll> A, B;
  ll a, b;
  REP(n, N){
    cin >> a >> b;
    A.PB(a);
    B.PB(b);
  }
  sort(ALL(A));
  sort(ALL(B));

  ll mmin, mmax;
  if(N % 2 == 0){
    mmin = A[N/2 - 1] + A[N/2];
    mmax = B[N/2 - 1] + B[N/2];
  }else{
    mmin = A[(N-1) / 2];
    mmax = B[(N-1) / 2];
  }
  cout << (mmax - mmin + 1) << endl;
  return 0;
}


Measured memory_bytes: 6256