akhauriyash/Code-Regression huggingface dataset:
h,w = list(map(int, input().split()))

maze = []
maze.append(['#'] * (w+2))
for i in range(h):
    row = [c for c in input()]
    row.insert(0, '#')
    row.append('#')
    maze.append(row)
maze.append(['#'] * (w+2))

def search(item):
    x, y, dist = item
    ret = [
        (x+i,y+j, dist+1) for (i,j)
        in [(1,0), (-1,0), (0,1), (0,-1)]
        if maze[x+i][y+j] == '.'
    ]
    return ret

def bfs(fn, todo):
    seen = dict()
    for item in todo:
        x, y, d = item
        seen[(x, y)] = True    
    
    longest = 0
    while len(todo) > 0:
        # print("todo", todo)
        # print("seen", seen.keys())
        # print("longest", longest)
        item, todo = todo[0], todo[1:]
        x, y, dist = item
        if dist>longest:
            longest = dist

        for a in fn(item):
            x, y, dist = a
            if (x, y) in seen:
                continue
            seen[(x,y)] = True
            todo.append(a)

    return longest

def calc(x, y):
    return bfs(search, [(x, y, 0)])

longest_longest = 0

for i in range(1, h+1):
    for j in range(1, w+1):
        if maze[i][j] == "#":
            continue
        longest = calc(i, j)

        if longest_longest < longest:
            longest_longest = longest  

print(longest_longest)


Measured memory_bytes: 3188
S=list(input())
L=len(S)
mod=10**9+7
dp=[[0]*13 for _ in range(2)]
dp[0][0]=1
now,next=1,0
for i in range(L):
	c=S[i]
	now,next=next,now
	for j in range(13):
		if c=='?':
			for k in range(10):
				dp[next][(j*10+k)%13]+=dp[now][j]
		else:dp[next][(j*10+int(c))%13]+=dp[now][j]
	for j in range(13):
		dp[next][j]%=mod
		dp[now][j]=0
print(dp[next][5])

Measured memory_bytes: 49648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define S second
#define F first
#define ii pair <int,int>
#define IOS std::ios_base::sync_with_stdio(false)
#define pb push_back

const ll inf = 1e18;
int q = 1 ;
const int N = 1e5+10 ;
ll n , a[N], mem[N],k;
ll dp(int i)
{
    if(i == n-1)
        return 0ll;
    ll &ret =mem[i];
    if(ret != -1)
        return ret;
    ll p1 = inf;
    for(int j = 1 ; j <= k ; j++)
        if(i + j < n)
            p1 = min(p1,abs(a[i+j] - a[i]) + dp(i+j));
    return ret = p1;
}
void solve()
{
    cin>>n>>k;
    for(int i = 0 ; i < n;i++ )
        cin>>a[i];
    memset(mem,-1,sizeof mem);
    cout<<dp(0);
}


int main()
{
    IOS;
//    cin>>;
    while(q--)
    {
         solve();
    }

}


Measured memory_bytes: 8064
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if (a+b)%2 == 1 {
		fmt.Println((a+b)/2 + 1)
	} else {
		fmt.Println((a+b)/2 + 0)
	}
}


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

int root(int n){
  long long t = n;
  while(1) {
    t = (t*t+n)/(2*t);
    if (t*t <= n) return (int)t;
  }
}
int main(){
  int n, i = 5, r, m = 0;;

  cin >> n;
  cout << n << ":";
  while(n%2 == 0){
    n /= 2;
    cout << " " << 2;
  }
  if (n == 1){cout << endl; return 0;}
  while(n%3 == 0){
    n /= 3;
    cout << " " << 3;
  }
  if (n == 1){cout << endl; return 0;}
  
  r = root(n);
  while(i <= r){
    if (n%i == 0) {
      cout << " " << i;
      n /= i;
      r = root(n);
    }
    else {if (m ^= 1) i += 2; else i += 4;}
  }
  cout << " " << n << endl;
  return 0;
}

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

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

  long count = 0;
  for(long i=0; i<S.size(); i++){
    if(S[i] == '0'){
      count++;
    }
  }


  long a = S.size()-count;
  cout << min(a, count)*2 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,e=0;
    cin>>a>>b;
    char c[a+b+1];
    for(int i=0;i<a+b+1;i++) cin>>c[i];
    for(int i=0;i<a+b+1;i++){
    if(c[i]>='0'&&c[i]<='9') e++;
    }
    if(a+b==e&&c[a]=='-') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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


def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
#print(a, b)
#print(a.intersection(b))
ans = len(a.intersection(b))
print(ans)


Measured memory_bytes: 9192
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

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

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

	int n;
	scanf("%d", &n);
	vector < int > a(n), b(n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &a[i], &b[i]);
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		ans += (b[i] - (a[i] + ans) % b[i]) % b[i];
	}
	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 1024
import math
from itertools import permutations
def generate_permutations(n):
    perms = permutations(range(1, n+1), n)
    return [perm for perm in perms]
 
n = int(input())
ptuple = tuple(map(int, input().split()))
qtuple = tuple(map(int, input().split()))
 
perms = generate_permutations(n)
a = perms.index(ptuple)
b = perms.index(qtuple)
print(int(math.fabs(a - b)))

Measured memory_bytes: 44656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long A, long long B, long long C)
{
    if(A%2==0||B%2==0||C%2==0){
        cout << 0 << endl;
    }else{
        cout << min(A*C,min(A*B,B*C)) << endl;
    }
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N, M;
    cin >> N >> M;
    vector<ll>A(N + 1, 0);
    vector<ll>B(N + 1, 0);
    for(ll i = 0; i < M; i++){
        ll a, b;
        cin >> a >> b;
        if(a == 1)A[b] = 1;
        if(b == N)B[a] = 1;
    }
    for(ll i = 2; i < N; i++){
        if(A[i] && B[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 3328
s = gets.to_i
cnt = 1
arr = [s]
if (s == 2) || (s==1)
  puts 4
  exit
else
  while true
    if arr[cnt-1].even?
      arr << arr[cnt-1] / 2
      cnt += 1
    else arr[cnt-1]
      x = arr[cnt-1]*3
      x += 1
      arr << x
      cnt += 1
    end
  break if arr.index(4)
  end
end

p arr.index(4) + 4


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

using namespace std;

typedef long long ll;

#define sz(s) (int)s.size()
#define endl '\n'

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main() {
	//PLAY();
	
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	string res = "";
	for (int i = 0; i < n; i++) {
		res += a[i];
		res += b[i];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  i = 1
  while i*i <= n:
    if n % i == 0:
      ans = n//i
    i+=1
  print(len(str(ans)))
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
import sys

MOD = 10**9+7

N,K = map(int, input().split())
A = [[abs(int(x)),1 if int(x)<0 else 0] for x in input().split()]
A.sort(key=lambda x: x[0],reverse=True)
prod = 1
pn = 0
lastn = -1
lastp = -1


for i in range(K):
    if A[i][1] == 1: lastn = i
    else: lastp = i
    pn = (pn + A[i][1]) % 2


if pn == 0:
    if K == N and [0,0] in A:
        print(0)
        sys.exit()
    for i in range(K):
        prod = prod * A[i][0] % MOD
    print(prod)
    sys.exit()

elif pn == 1:
    if K == N:
        if [0,0] in A:
            print(0)
            sys.exit()
        for i in range(N):
            prod = prod * A[i][0] % MOD
        prod = prod * (-1) % MOD
        print(prod)
        sys.exit()
    indp = K
    indn = K
    while indp < N and A[indp][1] == 1:
        indp += 1
    while indn < N and A[indn][1] == 0:
        indn += 1
    if lastp == -1 and indp == N:
        for i in range(K):
            prod = prod * A[-1-i][0] % MOD
        prod = prod * (-1) % MOD
    elif indp == N:
        for i in range(K):
            if i == lastp:
                prod = prod * A[indn][0] % MOD
            else:
                prod = prod * A[i][0] % MOD
    elif lastp == -1 or indn == N:
        for i in range(K):
            if i == lastn:
                prod = prod * A[indp][0] % MOD
            else:
                prod = prod * A[i][0] % MOD
    else:
        for i in range(K):
            if A[indp][0] * A[lastp][0] > A[indn][0] * A[lastn][0]:
                if i == lastn:
                    prod = prod * A[indp][0] % MOD
                else: prod = prod * A[i][0] % MOD
            else:
                if i == lastp:
                    prod = prod * A[indn][0] % MOD
                else:
                    prod = prod * A[i][0] % MOD
    print(prod)

Measured memory_bytes: 116232
//file_name:ABC84_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);


    int ans = 48 - n;

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



Measured memory_bytes: 256
n=int(input())

S = [0] * 13
H = [0] * 13
C = [0] * 13
D = [0] * 13

cnt = 1

while cnt <= n:
    e = input().split()
    idx = int(e[1]) - 1
    if e[0] == "S":
        S[idx] = 1
    elif e[0] == "H":
        H[idx] = 1
    elif e[0] == "C":
        C[idx] = 1
    elif e[0] == "D":
        D[idx] = 1
    cnt += 1

for idxs in range(13):
    if S[idxs] == 0:
        print("S {}".format(idxs + 1))

for idxs in range(13):
    if H[idxs] == 0:
        print("H {}".format(idxs + 1))

for idxs in range(13):
    if C[idxs] == 0:
        print("C {}".format(idxs + 1))

for idxs in range(13):
    if D[idxs] == 0:
        print("D {}".format(idxs + 1))



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

using namespace std;

int main()
{
    double a, b, v1, v2, T;
    cin >> a >> v1 >> b >> v2 >> T;
    if(v1 == v2|| v2 > v1){cout << "NO" << endl ; return 0;}


        double t;
        t = (abs(a - b)/(v1-v2));
        if(t > T){
            cout << "NO"<< endl;
        }else{
        cout << "YES" << endl;
        }

    return 0;
}


Measured memory_bytes: 3780
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var S = new string[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = Console.ReadLine();
        }

        var hash = new HashSet<string>(S);
        Console.WriteLine(hash.Count);
    }
}

Measured memory_bytes: 42500
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MXN = 3e3;
int dp[MXN+5][MXN+5];
string A,B;


int rec(int ii, int jj){
    if(ii>=A.size() || jj>=B.size()) return 0;
    int &ret = dp[ii][jj];
    if(ret!=-1) return ret;
    if(A[ii]==B[jj]) return ret = rec(ii+1,jj+1) + 1;
    return ret = max ( rec(ii+1,jj) , rec(ii,jj+1) );
}

void watch(){
    for(int i=0; i<A.size(); i++){
        for(int j=0; j<B.size(); j++){
            cout<<setw(2)<<dp[i][j];
        }cout<<"\n";
    }cout<<"\n";
}

void solve(){

    memset(dp,-1,sizeof(dp));
    cin>>A>>B;
    int lcs_len = rec(0,0);
    int i=0,j=0;
    while(lcs_len){
        if(dp[i][j]==dp[i][j+1]) j++;
        else if(dp[i][j]==dp[i+1][j]) i++;
        else{
            cout<<A[i];
            i++,j++;
            lcs_len--;
        }
    }cout<<"\n";


}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}


Measured memory_bytes: 35840
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();
        System.out.println((a*b));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


Measured memory_bytes: 32656
#include <iostream>
 
using namespace std;
 
int main()
{
    int a, x;
    while (cin >> a >> x) {
        if (a == 0 && x == 0) break;
        int ans = 0;
        for (int i = 1; i <= a - 2; i++) {
            for (int j = i + 1; j <= a - 1; j++) {
                for (int k = j + 1; k <= a; k++) {
                    if (i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var mfb = ReadInts();
            var tarinai = mfb[2] - mfb[0];
            if (tarinai > 0)
            {
                if (tarinai <= mfb[1])
                {
                    WriteLine(tarinai);
                }
                else
                {
                    WriteLine("NA");
                }
            }
            else
            {
                WriteLine(0);
            }
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18004
import sys
from io import StringIO
import unittest
import os
import heapq

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n, m = map(int, input().split())
    a_s = list(map(int, input().split()))
    bc_s = [list(map(int, input().split())) for i in range(m)]

    # 優先度付きキューの作成
    a_que = []
    heapq.heapify(a_que)
    b_que = []
    heapq.heapify(b_que)

    # (値,使用回数)setをキューに追加
    for a in a_s:
        heapq.heappush(a_que, a)
    for bc in bc_s:
        heapq.heappush(b_que, (-bc[1], bc[0]))

    ans = []
    now_b = 0
    choise_cnt = 0
    for i in range(m):

        now_b, b_cnt = heapq.heappop(b_que)
        now_b = -now_b

        for j in range(b_cnt):
            if choise_cnt >= n or len(a_que) == 0:
                break
            now_a = heapq.heappop(a_que)
            if now_b >= now_a:
                ans.append(now_b)
                choise_cnt += 1

    # ans = 採用するbの値の一覧
    a_s = sorted(a_s, reverse=True)
    for i in range(n - choise_cnt):
        ans.append(a_s[i])

    print(sum(ans))


# テストクラス

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

    def test_input_1(self):
        test_input = """3 2
5 1 4
2 3
1 5"""
        output = """14"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4"""
        output = """338"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """3 2
100 100 100
3 99
3 99"""
        output = """300"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000"""
        output = """10000000001"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 110264
n, q = map(int, input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i:i+2] == "AC" else 0)
for j in range(q):
    l, r = map(int, input().split())
    ans = t[r-1] - t[l-1]
    print(ans)

Measured memory_bytes: 7748
#include<stdio.h>

#include<string.h>
#define N 256

char array1[1<<21],arrayk[N];

int main(int argc,char *argv[]){
char cha;
int numf;

int numv,nums,numt;
  

arrayk['T'] = 1;
arrayk['G'] = 2;
  arrayk['C'] = 3;
  arrayk['A'] = 4;
   
  scanf("%d", &numv);

  getchar();

  while (numv--) {
    nums = 0;
    numt = 1;

    numf = ( cha = getchar() ) == 'i';

    while ( ( cha = getchar() ) != ' ' );

    while ( ( cha = arrayk[getchar()] ) != 0 ) {

      nums += cha * numt;

      numt *= 4;
    } 

    if (numf) array1[nums] = 1; 
else puts( array1[nums] ? "yes" : "no" );

  }

  return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
ll n,p;
cin>>n>>p;
map<ll,int> m;
for(ll i=2;i*i<=p;i++){
  while(p%i==0){
    m[i]++;
    p/=i;
  }
}
if(p!=1) m[p]++;
ll ans=1;
for(auto i:m){
 //cout<<i.first<<"^"<<i.second<<endl;
  if(i.second>=n){
    for(int w=0;w<i.second/n;w++) ans*=i.first;
  }
}
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
  if nsame == 2:
    cnt2 += 1
  elif nsame == 1:
    cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)
    

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
// using mP = pair<modint, modint>;

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




void solve() {
    int K, A, B; cin >> K >> A >> B;
    bool flg = false;
    Rep1(i, A, B){
        if(i % K == 0) flg = true;
    }

    if(flg) cout << "OK" << endl;
    else cout << "NG" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7752
#include<stdio.h> 
#define INFINITO 1000000000
  
long long int max(long long a, long long b) { return (a > b)? a : b; } 
long long int min(int a, int b) { return (a < b)? a : b; }
long long int distancia(long long a, long long b) { return max(a,b) - min(a,b); }

int main() { 

	long long i,j;
	long long int n, k;
	scanf("%lld %lld", &n,&k);
	long long int vet[n+10], dp[n+10];
		
	for(i=1; i<=n; i++)
    	scanf("%lld", &vet[i]);
 
	for(i=0; i<=n; i++)
		dp[i] = INFINITO;
	dp[1] = 0;

	for(i=2; i<=n; i++) {
		//printf("dp[%lld] = %lld\n", i-1, dp[i-1]);
		for(j=1; j<=k; j++) {
			if( i-j > 0 ) {
				dp[i] = min( dp[i], dp[i-j] + distancia( vet[i-j] , vet[i] ) );
			} else {
				break;
			}
		}
	}
	//printf("dp[%lld] = %lld\n", n, dp[n]);
	printf("%lld\n", dp[n]); 

	return 0; 
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define maxn 2000006
#define mod 1000000007
using namespace std;

int x[6],y[6];
int fac[maxn]={1,1},inv[maxn]={1,1},invf[maxn]={1,1};
int C(int n,int m){ if(n<0||m<0||n-m<0) return 0;return fac[n] * 1ll * invf[m] % mod * invf[n-m]%mod; }
int P(int n,int m){ return C(n+m,n); }
int Py(int a,int b){ return (1ll * P(x[5]+1-a,y[5]+1-b) - P(x[4]-a,y[5]+1-b) - P(x[5]+1-a,y[4]-b) + P(x[4]-a,y[4]-b)) % mod; }
int Pz(int a,int b){ return (1ll * P(a-x[0]+1,b-y[0]+1) - P(a-x[1],b-y[0]+1) - P(a-x[0]+1,b-y[1]) + P(a-x[1],b-y[1])) % mod; }


int main(){
	for(int i=0;i<6;i++) scanf("%d",&x[i]);
	for(int i=0;i<6;i++) scanf("%d",&y[i]);
	for(int i=2;i<maxn;i++) fac[i] = 1ll * fac[i-1] * i % mod,
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod,
		invf[i] = 1ll * invf[i-1] * inv[i] % mod;
	int ans = 0;
	for(int i=x[2];i<=x[3];i++) ans = (ans + 1ll * Py(i,y[3]+1) * Pz(i,y[3]) % mod * (i+y[3]+1)) % mod;
	for(int i=x[2];i<=x[3];i++) ans = (ans - 1ll * Py(i,y[2]) * Pz(i,y[2]-1) % mod * (i+y[2])) % mod;
	for(int i=y[2];i<=y[3];i++) ans = (ans + 1ll * Py(x[3]+1,i) * Pz(x[3],i) % mod * (i+x[3]+1)) % mod;
	for(int i=y[2];i<=y[3];i++) ans = (ans - 1ll * Py(x[2],i) * Pz(x[2]-1,i) % mod * (i+x[2])) % mod;
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 23680
n,X = map(int,input().split())
x = list(map(int,input().split()))

x.sort()
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
ans = abs(x[0]-X)
if len(x) == 1:
    print(ans)
else:
    for i in x[1:]:
        ans = gcd(abs(i-X),ans)
    print(ans)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();

	int N; cin >> N;
	vector<ll>vec(N + 1, 0);
	rep(i, 1, N + 1) {
		for (int j = i;j <= N;j += i) {
			vec[j]++;
		}
	}
	ll ans = 0;
	rep(i, 1, N + 1) {
		ans += i * vec[i];
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 81332
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll dp[MAXN][14];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>S;

    n = strlen(S);

    reverse(S,S+n);

    ll base = 10;

    if(S[0]=='?'){
        for(int j=0;j<10;j++)
            dp[0][j] = 1;
    }
    else {
        dp[0][S[0]-'0'] = 1;
    }

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

        if(S[i]=='?'){

            for(int t=0;t<10;t++){
                cur = t*base;
                cur%=13;
                for(int j=0;j<13;j++){
                    dp[i][j]+=dp[i-1][(j+13-cur)%13];
                    dp[i][j]%=MOD;
                }
            }
        }
        else {
            cur = base*(S[i]-'0');
            cur %= 13;
            for(int j=0;j<13;j++){
                dp[i][j] = dp[i-1][(j+13-cur)%13];
            }
        }
        base*=10; base%=13;
    }

    cout<<dp[n-1][5]<<"\n";

    return 0;
}


Measured memory_bytes: 12416
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

string s;

int main(){
	ios::sync_with_stdio(false);
	cin>>s;
	int cur=0;
	while(cur<s.size()){
		if(s.size()-cur<5){
			cout<<"NO";
			return 0;
		}
		if(s[cur]=='d'&&s[cur+1]=='r'&&s[cur+2]=='e'&&s[cur+3]=='a'&&s[cur+4]=='m'){
			if(s[cur+5]!='e'||s[cur+6]!='r')cur+=5;
			else{
				if(s[cur+7]=='a')cur+=5;
				else cur+=7;
			}
		}
		else if(s[cur]=='e'&&s[cur+1]=='r'&&s[cur+2]=='a'&&s[cur+3]=='s'&&s[cur+4]=='e'){
			if(s[cur+5]!='r')cur+=5;
			else cur+=6;
		}
		else {
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int tmp;
  for (int i = 0; i < n; i++) cin >> tmp;
  if ((n - 1) % (k - 1)) {
    cout << (n - 1) / (k - 1) + 1;
  }
  else {
    cout << (n - 1) / (k - 1);
  }
}


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

int main() {
  long long N;
  cin>>N;
  // long long A = (N-1)* N /2;
  // cout<<A<<endl;
  cout<<(N-1)* N /2<<endl;

  return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
l = L % 2019
b = min(R - L, 2019)
ans = 10 ** 12
for i in range(l, l + b + 1):
    for j in range(i + 1, l + b + 1):
        ans = min(ans, i * j % 2019)
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n;
vector<int> edge[101];
int door[101];
int route[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		memset(door,0,sizeof(door));
		memset(route,0,sizeof(route));
		for(int j=0;j<100;j++){
			edge[j].clear();
		}
		int cnt=0,depth=0;
		while(1){
			int x;
			scanf("%d",&x);
			if(x==0){
				for(int i=0;i<cnt;i++){
					printf("%d ",i+1);
					sort(edge[i].begin(),edge[i].end());
					for(int j=0;j<edge[i].size();j++){
						printf("%d%c",edge[i][j]+1,j+1==edge[i].size()?'\n':' ');
					}
				}
				break;
			}
			if(x>0){
				while(depth>1 && door[route[depth-1]]==edge[route[depth-1]].size())depth--;
				door[cnt]=x;
				route[depth]=cnt;
				if(depth>0){
					edge[cnt].push_back(route[depth-1]);
					edge[route[depth-1]].push_back(cnt);
				}
				depth++;
				cnt++;
			}
			if(x<0){
				while(depth>1 && door[route[depth-1]]==edge[route[depth-1]].size())depth--;
				edge[route[depth-1]].push_back(route[x+depth-1]);
				edge[route[x+depth-1]].push_back(route[depth-1]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1228
import bisect
 

def main():
    n = int(input())
    ls = sorted(list(map(int, input().split())))
 
    ans = 0
    for i in range(n-1):
        for j in range(i+1, n):
            a = ls[i]
            b = ls[j]
            k = bisect.bisect_left(ls, a+b)
            if k > j:
                ans += k - j - 1
    print(ans)
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define MOD 1000000007
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define read(a, n) for(ll i = 0;i<n;i++) cin>>a[i];
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
const int INF = 1e9 + 5;

void solve() {
	ll n, k;
	cin>>n>>k;
	
	ll h[n];
	read(h, n);
	
	ll dp[n];
	memset(dp, 0, sizeof(dp));
	
	dp[0] = 0;
	
	for(ll i = 1;i<n;i++) {
		ll min = INT_MAX;
		for(ll j = 1;j<=k;j++) {
			if(i-j >= 0) {
				if(dp[i-j] + abs(h[i] - h[i-j]) < min) {
					min = dp[i-j] + abs(h[i] - h[i-j]);
				}
			}
			else break;
		}
		dp[i] = min;
	}
	
	cout<<dp[n-1]<<"\n";
}

int main()
{
	fastio;
	
	int T = 1;
	//cin>>T;
	//int tc = 1; 
	while(T--) {
		//cout<<"Case #"<<tc<<": ";
		solve();
		//tc++;
	}	
	return 0;
}


Measured memory_bytes: 5176
#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); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9




int main(){
  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  REP(i, H){
    cin >> C[i];
  }

  REP(i, H){
    cout << C[i] << endl;
    cout << C[i] << endl;
  }



  return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
    string s, t;
    cin >> s >> t;

    map<char, char> stot, ttos;

    bool ok = true;

    for(int i = 0; i < s.size(); i++){
        char si = s[i];
        char ti = t[i];

        if(stot.count(si) && stot[si] != ti)ok = false;
        if(ttos.count(ti) && ttos[ti] != si)ok = false;

        stot[si] = ti;
        ttos[ti] = si;
    }
    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 776
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    num = int(input())
    s = list(map(int,input().split()))
    ans = 0
    for i in range(num - 1):
        for j in range(i + 1, num):
            ans += s[i] * s[j]

    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 39148
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,n);
  Vi A(n);
  VIN(A)
  x = VSUM(A);
  Yes(x >= a);
}

Measured memory_bytes: 1024
import sys

def add_char(l, string):
    for s in string:
        l.append(s)

n = int(sys.stdin.readline().strip())
common_list = []

for i in range(n):
    s = sys.stdin.readline().strip()
    if i == 0:
        add_char(common_list, s)
    else:
        tmp = []
        add_char(tmp, s)
        tmp_c = list(common_list)
        for c in tmp_c:
            if c in tmp:
                tmp.remove(c)
            else:
                common_list.remove(c)
if len(common_list) == 0:
    print("")
else:
    common_list = sorted(common_list)
    s = ""
    for c in common_list:
        s += c
    print(s)


Measured memory_bytes: 3064
N, M = map(int, input().split())
ppp = 10**9 + 7

def fac(n):
    r = [1]*(n+1)
    for i in range(1, n+1):
        r[i] = r[i-1] * i % ppp
    return r[n]

if abs(N-M) > 1:
    print(0)
elif N - M == 0:
    print(fac(N)**2*2%ppp)
else:
    print(fac(N)*fac(M)%ppp)


Measured memory_bytes: 6900
N,K,S=map(int,input().split())
l=[0]*N
if S==10**9:
    for i in range(N):
        if i<K:
            l[i]=str(S)
        else:
            l[i]=str(1)
else:
    for i in range(N):
        if i<K:
            l[i]=str(S)
        else:
            l[i]=str(10**9)
print(" ".join(l))

Measured memory_bytes: 13300
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static long mod = 998244353;

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var tbl = new long[n];
        long max = 0;

        var spl =input.ReadLine().Split(' ');
        for (int i = 0; i < n; i++) {
            var d = long.Parse(spl[i]);
            tbl[d]++;
            max = Math.Max(d, max);
        }

        if (spl[0] != "0") return 0;
        if (tbl[0] != 1) return 0;

        long sum = 1;

        for(int i=1; i<=max; i++) {
            if (tbl[i] == 0) return 0;

            long pre = tbl[i - 1];
            sum *= pow(pre, tbl[i]) % mod;
            //Debug.WriteLine(sum);
            sum %= mod;
        }
        return sum;
    }

    static long pow(long n, long m) {
        long ret = n;
        for(long i=1; i<m; i++) {
            ret *= n;
            ret %= mod;
        }
        return ret;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl =strs.Split(' ');
        for (long i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 18272
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    auto s = new string[](h);
    foreach (ref e; s)
        e = sread();
    auto cost = new long[][](h, w);
    long cntwhite;
    foreach (i; iota(h))
    {
        foreach (j; iota(w))
        {
            if (s[i][j] == '.')
            {
                cost[i][j] = -1;
                cntwhite++;
            }
            else
                cost[i][j] = INF;
        }
    }

    //  迷路の探索はBFSのがいいよね
    auto q = new DList!(Pair)(Pair(0, 0, 1));
    while (!q.empty())
    {
        auto c = q.front();
        q.removeFront();
        if (c.x - 1 >= 0 && cost[c.x - 1][c.y] < 0)
        {
            q.insertBack(Pair(c.x - 1, c.y, c.cost + 1));
            cost[c.x - 1][c.y] = c.cost + 1;
        }
        if (c.x + 1 < h && cost[c.x + 1][c.y] < 0)
        {
            q.insertBack(Pair(c.x + 1, c.y, c.cost + 1));
            cost[c.x + 1][c.y] = c.cost + 1;
        }
        if (c.y - 1 >= 0 && cost[c.x][c.y - 1] < 0)
        {
            q.insertBack(Pair(c.x, c.y - 1, c.cost + 1));
            cost[c.x][c.y - 1] = c.cost + 1;
        }
        if (c.y + 1 < w && cost[c.x][c.y + 1] < 0)
        {
            q.insertBack(Pair(c.x, c.y + 1, c.cost + 1));
            cost[c.x][c.y + 1] = c.cost + 1;
        }
    }
    if (cost[h - 1][w - 1] > 0)
        writeln(cntwhite - cost[h - 1][w - 1]);
    else
        writeln(-1);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

const int INF = 2147483647;
const int Maxn = 2010;
struct edge {
    int To, Next;
};
edge Edge[ Maxn << 1 ];
int Start[ Maxn ], Used;
int X[ Maxn ], Y[ Maxn ], n, k;

inline void AddEdge( int x, int y ) {
    Edge[ ++Used ] = ( edge ) { y, Start[ x ] };
    Start[ x ] = Used;
    return;
}

int Cnt( int Index, int Father, int Res ) {
    int Num = 1;
    if( Res == 0 ) return Num;
    for( int t = Start[ Index ]; t; t = Edge[ t ].Next ) {
        int v = Edge[ t ].To;
        if( v == Father ) continue;
        Num += Cnt( v, Index, Res - 1 );
    }
    return Num;
}

void Work1() {
    int Ans = INF;
    for( int i = 1; i <= n; ++i ) 
        Ans = min( Ans, n - Cnt( i, 0, k / 2 ) );
    printf( "%d\n", Ans );
    return;
}

void Work2() {
    int Ans = INF;
    for( int i = 1; i < n; ++i ) 
        Ans = min( Ans, n - Cnt( X[ i ], Y[ i ], k / 2 ) - Cnt( Y[ i ], X[ i ], k / 2 ) );
    printf( "%d\n", Ans );
}

int main() {
    scanf( "%d%d", &n, &k );
    for( int i = 1; i < n; ++i ) {
        scanf( "%d%d", &X[ i ], &Y[ i ] );
        AddEdge( X[ i ], Y[ i ] );
        AddEdge( Y[ i ], X[ i ] );
    }
    if( k % 2 == 0 ) Work1(); else Work2();
    return 0;
}

Measured memory_bytes: 384