akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int p, q, r;
    cin >> p >> q >> r;
    int sum = 0;
    sum += min(min((p + q), (p + r)), (r + q));
    cout << sum;
    
    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int res = 0;
  long long d;
  cin >> d;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    res += (x * x + y * y <= d * d);
  }
  cout << res << endl;
}


Measured memory_bytes: 3620
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    if(n==22):
        print("Christmas Eve Eve Eve")
    if(n==23):
        print("Christmas Eve Eve")
    if(n==24):
        print("Christmas Eve")
    if(n==25):
        print("Christmas")
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>


using namespace std;

void dump(vector<int> flowers)
{
    for (auto e : flowers)
        cout << e << " ";
    cout << endl;
}

bool done(vector<int> flowers)
{
    for (auto e : flowers)
        if (e != 0)
            return false;
    return true;
}


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

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

    int ans = 0;
    while (!done(flowers)) {
        int l, r;
        l = 0;
        r = 1;

        while (l < flowers.size() && r < flowers.size() + 1) {
            while (l < flowers.size() && flowers[l] == 0)
                l++;

            if (l >= flowers.size())
                break;

            r = l + 1;
            while (r < flowers.size() + 1 && flowers[r] > 0)
                r++;

            for (int i = l; i < r; i++) {
                flowers[i]--;
            }
            l = r;
            // dump(flowers);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i = 0; i < N; i++){
    cin >> num[i];
  }
  int tmp;
  for(int i = 0; i < N; i++){
    for(int j = 1; j< N; j++){
      if(num[j] > num[j-1]){
        tmp = num[j];
        num[j] = num[j-1];
        num[j-1] = tmp;
      }
    }
  }
  int X = 1;
  for(int i = 1; i < N; i++){
    if(num[i] < num[i-1]){
      X++;
    }
  }
  cout << X << endl;
}

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

int main(){
  int N,H,Hmax=0,ans=0;
  cin >> N;
  for(int i=0; i<N; ++i){
    cin >> H;
    if(H >= Hmax){
      Hmax = H;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int vday;
  int wday;
  scanf("%d",&vday);
  scanf("%d",&wday);
  int work[wday];
  int i;
  for(i = 0;i < wday;++i) {
    scanf("%d",&work[i]);
  }
  int sum = 0;
  for(i = 0;i < wday;++i) {
    sum += work[i];
  }
  if(sum > vday) {
    puts("-1");
  }
  else {
    printf("%d\n",vday - sum);
  }
  return 0;
}

Measured memory_bytes: 1708
def main():
    n = int(input())
    n_array = []
    for i in range(n):
        word = input()
        n_array.append(word)
    m = int(input())
    m_array = []
    for i in range(m):
        word = input()
        m_array.append(word)
    n_dic = {}
    m_dic = {}
    best = 0
    for i in n_array:
        if i in n_dic:
            n_dic[i] += 1
        else:
            n_dic[i] = 1
    for i in m_array:
        if i in m_dic:
            m_dic[i] += 1
        else:
            m_dic[i] = 1
    for i in n_dic:
        if i in m_array:
            if n_dic[i] - m_dic[i] > best:
                best = n_dic[i] - m_dic[i]
        else:
            if n_dic[i] > best:
                best = n_dic[i]
    print(best)

main()

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))

    come = [None] * N

    for i, x in enumerate(A):
        come[x - 1] = (i + 1)

    print(*come)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13388
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    int n, k;
    cin >> n >> k;
    vector <int> seq(n);
    for (int i = 0; i < n; ++i)
        cin >> seq[i];
    int l = 0, r = 1e9 + 1;
    while (r - l > 1)
    {
        int m = (l + r) / 2;
        int cnt = 0;
        for (int i = 0; i < n; ++i)
            cnt += seq[i] / m + (int)(bool)(seq[i] % m) - 1;
        if (cnt <= k)
            r = m;
        else
            l = m;
    }
    cout << r << endl;
}

Measured memory_bytes: 4716
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())



# def numtost(n):
    
def ok(num):
    nmst = "{0:d}".format(num)
    # print(nmst)
    if len(nmst) == len(list(filter(lambda x:x==nmst[0], nmst[:]))):
        return True
    else:
        # p = len(nmst)
        # q = len(list(filter(lambda x:x==nmst[0], nmst[1:])))
        # print(p,q,p==q)
        # print("len nmst: ", len(nmst))
        # print("filter : ", list(filter(lambda x: x==nmst[0], nmst)))
        # print("len filter : ", len(list(filter(lambda x: x==nmst[0], nmst))))
        # print(" equal : ", len(nmst) == len(list(filter(lambda x:x==nmst[0], nmst[1:]))))
        return False

for i in range(N, int(1e9)):
    if ok(i):
        print(i)
        exit(0)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
const ll N = 2e5+10;
const ll M=2005;

vector<ll>graph[N];
ll arr[N];


int main(){
    
        #ifdef debug
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout); 
            
        #endif
            ios_base::sync_with_stdio(0);
            cin.tie(0);cout.tie(0);
            
            /*ll T=1;
            while(T--){*/
                ll h=0,n=0,flag=0;
                ll x=0,ans=0;
                cin>>h>>n;
                vector<ll>get(h);
                
                if(n>=h){
                    ans=0;
                }
                
                else{
                 
                for(ll i=0;i<h;i++){
                    cin>>get[i];
                }
                sort(get.begin(),get.end(),greater<ll>());
                
                for(ll i=n;i<h;i++){
                    ans+=get[i];
                }
                
                
                }
                
                cout<<ans;
                
            //}
                
            
            
        return 0;
}

Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.Split.Double;
            var W = line[0];
            var H = line[1];
            var x = line[2];
            var y = line[3];

            var size = W * H;


            int bunkatu;
            if ((W / 2.0) == (double)x && (H / 2.0) == (double)y)
            {
                bunkatu = 1;
            }
            else if(W==0 || H== 0)
            {
                bunkatu = 1;
            }
            else
            {
                bunkatu = 0;
            }

            return $"{size / 2.0} {bunkatu}";
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> Split { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 13268
# coding: utf-8
import math
N, M = map(int,input().split())
#N = int(input())
#K = int(input())
#S = input()
ans = 0
#l = list(map(int,input().split()))
#A = list(map(int,input().split()))
F = [False] * (N+1)
pen = 0
P = [0] * (N+1)
for i in range(M):
    p, s = map(str,input().split())
    p = int(p)
    if s == "WA" and not F[p]:
        P[p] += 1
    if s == "AC" and not F[p]:
        ans += 1
        pen += P[p]
        F[p] = True

print(ans, pen)

Measured memory_bytes: 10320
#include<iostream>
#include<string>

using namespace std;

int main() {
  int sum = 0;
  int N;

  cin >> N;

  for(int i=1;i<=N;i++){
      sum += 800;
      if(i%15==0){
        sum -= 200;
      }
  }
  std::cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef pair<long long, int> P;
struct edge{
    int to;
    long long cost;
};
int main(){
    int N;
    cin >> N;
    vector<edge> G[N];
    for(int i = 0; i < N - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge e = {a, c}, e2 = {b, c};
        G[b].push_back(e);
        G[a].push_back(e2);
    }
    priority_queue<P> q;
    int Q, K;
    cin >> Q >> K;
    K--;
    long long INF = 1e18;
    vector<long long> d(N, INF);
    d[K] = 0;
    q.push(P(0, K));
    while(!q.empty()){
        P v = q.top();
        q.pop();
        if(v.first > d[v.second]) continue;
        long long dis = v.first;
        for(edge e:G[v.second]){
            if(d[e.to] > dis + e.cost){
                d[e.to] = dis + e.cost;
                q.push(P(d[e.to], e.to));
            }
        }
    }
    for(int i = 0; i < Q; i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << d[x] + d[y] << endl;
    }
}

Measured memory_bytes: 14104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            var A = N[0];
            var P = N[1];

            Console.WriteLine(Math.Floor((A * 3+P)/2));
            
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,W;
    cin>>n>>W;
    ll w[n+1];
    ll v[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][W+1];
    for(ll i=0;i<=W;i++)
    {
        dp[0][i]=0;
    }
    for(ll i=1;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=W;j++)
        {
            if(w[i]>j)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            }
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


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

int main() {
	string N;
    cin >> N;
    int s=N.size(), sum=0;
    vector<int> A[s];
    for (int i=0; i<s; i++){
      		if (N[i]=='1') sum+=1;
      		else if (N[i]=='2') sum+=2;
      		else if (N[i]=='3') sum+=3;
      		else if (N[i]=='4') sum+=4;
            else if (N[i]=='5') sum+=5;
            else if (N[i]=='6') sum+=6;
            else if (N[i]=='7') sum+=7;
            else if (N[i]=='8') sum+=8;
            else if (N[i]=='9') sum+=9;
   }
   if (sum%9==0) cout << "Yes" << endl;
   else cout << "No" << endl;
    
}




Measured memory_bytes: 14676
a,b,c,x,y = map(int,input().split())

smallestSum = 0
tempSum = 0

smallestSum = a * x + b * y

if x < y:
	tempSum = c * x * 2 + b * (y - x)
	if tempSum < smallestSum:
		smallestSum = tempSum
	tempSum = c * y * 2
	if tempSum < smallestSum:
		smallestSum = tempSum
else:
	tempSum = c * y * 2 + a * (x - y)
	if tempSum < smallestSum:
		smallestSum = tempSum
	tempSum = c * x * 2
	if tempSum < smallestSum:
		smallestSum = tempSum

print(smallestSum)

Measured memory_bytes: 61900
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(int x=0;x<n;x++)
    {
        cout<<s[x]<<t[x];
    }
}


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

void ABC168B()
{
	string S;
	int K;
	cin >> K;
	cin >> S;
	if (S.length() <= K)
	{
		cout << S << endl;
	}
	else
	{
		string T = S.substr(0, K);
		cout << T << "..." << endl;
	}
}


int main()
{
	ABC168B();
	return 0;
}

Measured memory_bytes: 3628
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    S = input()
    pos = len(S)

    while pos > 0:
        if S[pos - 5:pos] == 'dream' or S[pos - 5:pos] == 'erase':
            pos -= 5
        elif S[pos - 7:pos] == 'dreamer':
            pos -= 7
        elif S[pos - 6:pos] == 'eraser':
            pos -= 6
        else:
            print('NO')
            return None

    print('YES')


if __name__ == '__main__':
    solve()

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

//隣接リストのdijkstra
//refer abc070d
struct Edge{
    ll to, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
ll inf = 1e18;
vll dijkstra(const Graph &g, int s){
    vll d(g.size(), inf);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    while(!que.empty()){
        ll dist = que.top().first;
        int v = que.top().second;
        que.pop();
        if(d[v] < dist) continue;
        for(const auto &e: g[v]){
            if(d[e.to] <= d[v] + e.cost) continue;
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
        }
    }
    return d;
}

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

    ll n, m;
    cin >> n >> m;
    Graph g(n);
    ll l, r, c;
    REP(i, m) {
        cin >> l >> r >> c;
        l--, r--;
        g[l].push_back(Edge{r, c});
        g[r].push_back(Edge{l, c});
    }
    REP(i, n - 1) {
        g[i + 1].push_back(Edge{i, 0});
    }
    ll res = dijkstra(g, 0)[n - 1];
    if (res == inf) res = -1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 12664
#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

#define REP(i, x, n) for(int i = x, i##_len=(n); i < i##_len; i++)
#define rep(i,n) REP(i,0,n)
//#define DEBUG 3

void run() {
	int k, s;
	cin >> k >> s;
	long long int ans = 0;
	rep(i, k+1) {
		int ns = s - i;
		rep(j, k+1) {
			int nns = ns - j;
			if (0 <= nns && nns <= k) ans++;
		}
	}
	cout << ans << endl;

}

int main() {
#ifdef DEBUG
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	rep(i, DEBUG) {
		cout << "cnt:" << i << " ------------" << endl;
		run();
	}
#else
	run();
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n, a, b;
 cin >> n >> a >> b;
 int plan1 = a*n, plan2 = b;
 if (plan1 >= plan2){
   cout << plan2 << endl;
 }
 if (plan1 < plan2){
   cout << plan1 << endl;
 }
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

#define forn(i,s,n) for(ll i=s;i<n;i++)
#define all(c)  c.begin(),c.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(0);srand(time(NULL));
#define tc(t) ll t;cin >> t; while(t--)
/* cout << fixed << setprecision(12) << ans << endl;*/
#define pii pair<long long,long long>
#define vii vector<pii>
#define vvi vector<vector <long long> >

#define ff first
#define ss second

#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vector<int> , greater<int> >

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deba(a,n) for(ll i=0;i<n;++i) {  cout<<a[i]<<" "; };cout<<"\n"

#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
vector<vector<vector<double> > > dp(310 , vector<vector<double> >(310 , vector<double> (310,-1.0 )) );
ll n;

double solve(ll x, ll y , ll z)
{
	if(dp[x][y][z] >= 0.0)
    return dp[x][y][z];
	
	if(x<0 || y<0 || z < 0)
	return 0.0;
	if(x==0 && y==0 && z==0 )
	return 0.0;
	
	
		
	double ans=n;
	
	if(x>0)
	ans+= solve(x-1,y,z) * (double) x;
    if(y>0)
	ans+= solve(x+1,y-1,z) * (double) y;
	if(z>0)
	ans+= solve(x,y+1,z-1) * (double) z;	
	
	ans= ans / (double)(x+y+z);
	
	return dp[x][y][z]=ans;
	
	
}


int main()
{
 boost;
cin >> n;
ll a[3]={0};
 forn(i,0,n)
 {
 	ll id;cin >> id;
 	a[id-1]++;
 }
 cout << fixed << setprecision(12) << solve(a[0],a[1],a[2]) << endl;

}






Measured memory_bytes: 239616
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
    int n, mx = 0, mxans = 1;
    cin >> n;
    
    for(int i = 1; i < n+1; i++)
    {
        int a = 0, b = i;
        while (b)
        {
            if (b % 2 == 0)
            {
                b /= 2;
                a++;
            }
            else break;
        }
        if (mx < a)
        {
            mx = a;
            mxans = i;
        }
    }

    cout << mxans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> h(n);
  for(int i=0;i<n;i++) cin>>h[i];

  sort(h.begin(),h.end());
  ll sum=0;
  int len = n-k;
  if(len<0) len = 0;
  for(int i=0;i<len;i++){
    sum+=h[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 1792
import static java.util.Comparator.comparing;

import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==========================================================
    boolean[] dp;
    public void solve() {
    	int N = ni();
    	int K = ni();
    	int[] A = ndi(N);
    	dp = new boolean[K+1];
    	boolean win;
    	for (int i = 0; i <= K; i++) {
    		win = false;
			for (int j = 0; j < N; j++) {
				if(i - A[j] >= 0 && !dp[i-A[j]])	win = true;
			}
			if(win)			dp[i] = true;
		}
    	out.println(dp[K] ? "First" : "Second");
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(){
  int a,b,i,j,n;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0&&b==0){
      break;
    }
    for(i=0;i<a;i++){
      for(j=0;j<b;j++){
      printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return (0);
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define repi(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
using namespace std;
typedef long long ll;

int main() {
  int n,k; cin >> n >> k;
  string s; cin >> s;
  s[k-1] += 32;
  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 100000
int main(){
	int w,h;
	int i,j;
	int dp[101][101][2];
	while(1){
	scanf("%d %d",&w,&h);
	if(w==0)return 0;
	for(i=0;i<=h;i++){
		for(j=0;j<=w;j++){
			dp[i][j][0]=0;
			dp[i][j][1]=0;
			if(i==1||j==1){
				dp[i][j][0]=1;
				dp[i][j][1]=1;
			}
		}
	}
	for(i=2;i<=h;i++){
		for(j=2;j<=w;j++){
			dp[i][j][0]=(dp[i-2][j][1]+dp[i][j-2][0]+dp[i-2][j-1][1])%M;
			dp[i][j][1]=(dp[i-2][j][1]+dp[i][j-2][0]+dp[i-1][j-2][0])%M;
		}
	}
	printf("%d\n",(dp[h-1][w][1]+dp[h][w-1][0])%M);
	}
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long TwelvefoldWay11(long long n,long long k,long long MOD){
  return (n <= k ? 1 : 0);
}

signed main(){
  ll n,k;
  cin >> n >> k;
  cout << TwelvefoldWay11(n,k,INF) << endl;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n;
    cin >> n;
    vector< int> v(n);
    int mni = 0, mxi = 0;
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        if(v[i] < v[mni]) mni = i;
        if(v[i] > v[mxi]) mxi = i;
    }

    cout << 2 * n - 1 << endl;

    if(abs(v[mxi]) >= abs(v[mni])) {
        for(int i = 0; i < n; ++i) {
            cout << mxi + 1 << ' ' << i + 1<< endl;
        }

        for(int i = 0; i < n - 1; i++) {
            cout << i + 1 << ' ' << i + 2 << endl;
        }
    }

    else {
        for(int i = 1; i <= n; ++i) {
            cout << mni + 1 << ' ' << i << endl;
        }

        for(int i = n; i > 1; i--) {
            cout << i << ' ' << i - 1 << endl;
        }
    }


}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
  int g[1001][1001];//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      g[i][j]=0;
    }
  }
  for (int i = 0; i < n; ++i)
  {
    cin >> a >> b ;
    for (int i = 0; i < b; ++i)
    {
      cin >> c;
      g[a-1][c-1]=1;/* code */
    }
  }
  for (int i = 0; i < n; ++i)
  {
     for (int j = 0; j < n; ++j)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
  }

}

Measured memory_bytes: 1552
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
int ans = 1 << 30;

int main() {
	cin >> N;
	vector<int>W(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		sum += W[i];
	}
	int tmp = 0;
	for (int i = 0; i < N; i++) {
		tmp += W[i];
		ans = min(ans, abs(sum - 2*tmp));
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if (v == w):
    print('NO')
    sys.exit()
if (abs(a - b) / (v-w) > t or 0>(v-w)):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int k,a,b;
  	cin>>k;
  	cin>>a>>b;
  	if(b-a>k || a%k==0 || b%k==0 || b-a>k-(a%k)){
    	cout<<"OK"<<endl;
    }
  	else
      	cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    string t;
    cin >> t;
    for(int i=0;i<t.length();i++){
        if(t[i] == '?')t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3700
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int N;
    uint64_t K;
    std::cin >> N >> K;

    uint64_t A[N] = {0};

    uint64_t bitCnt[64] = {0};
    for (int i = 0; i < N; ++i) {
        std::cin >> A[i];
        uint64_t buf = A[i];
        int pos = 0;
        while (buf != 0) {
            int b = (buf & (0x0000000000000001));
            bitCnt[pos] += b;

            buf = (buf >> 1);
            ++pos;
        }
    }

    uint64_t x = 0;
    for (int i = 63; i >= 0; --i) {
        uint64_t buf = x;
        if (bitCnt[i] < (N - bitCnt[i])) {
            buf |= (1L << i);
            if (buf <= K) {
                x |= (1L << i);
            }
        }
    }

    uint64_t ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += (x ^ A[i]);
    }

    std::cout << ans << std::endl;

    return 0;
}

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

typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define pb                          push_back

const ll MX5 = 1*1e5+3;
const ll MX6 = 2*1e6+3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD2= 998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}

ll A[103],W[103];
ll dp[103][MX5];
int main(){
    fast_io
    //file_io
    ll n,w,ans=0;
    cin >> n >> w;
    for(int i=1;i<=n;i++){
        cin >> W[i] >> A[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=1;j<=1e5+2;j++){
            dp[i][j]=INF;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=1e5+2;j++){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j>=A[i]){
                dp[i][j]=min(dp[i][j],dp[i-1][j-A[i]]+W[i]);
                //error(dp[i][j])
            }
        }
    }
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<1e5+2;j++){
            if(dp[i][j]<=w){
                ans=max(ans,j);
            }
        }
    }
    cout << ans;
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = -1;
  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    int num = 0;
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i + j) == t.at(j)) num++;
    }
    ans = max(ans, num);
  }
  ans = t.size() - ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#Nはノード数、Mはエッジ数
N, M = map(int, input().split())

path_matrix = []

#無向行列の初期化
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    line = map(int, input().split())
    paths = [x - 1 for x in line]
    path_matrix[paths[0]][paths[1]] = True
    path_matrix[paths[1]][paths[0]] = True

#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N


#再帰関数、ここが難しいかもしれない。
def dfs(now, depth):
    if visited[now]:
        return 0
    if depth == N - 1:
        return 1

    visited[now] = True
    total_paths = 0
    for i in range(0, N):
        if path_matrix[now][i]:
            total_paths += dfs(i, depth + 1)

    visited[now] = False

    return total_paths

print(dfs(0, 0))

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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread!ulong();
    long[long] D;
    foreach (a; A)
    {
        if (a !in D)
            D[a] = 0;
        D[a]++;
    }
    if (0 in D && D[0] == N)
    {
        writeln("Yes");
        return;
    }
    if (0 in D && D.keys.length == 2 && D[0] == N / 3)
    {
        writeln("Yes");
        return;
    }
    if (D.keys.length == 3 && (D.keys[0] ^ D.keys[1] ^ D.keys[2]) == 0
            && D[D.keys[0]] == N / 3 && D[D.keys[1]] == N / 3 && D[D.keys[2]] == N / 3)
    {
        writeln("Yes");
        return;
    }
    writeln("No");
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

const ll MOD = 998244353;

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

	int n, a, b, c; cin >> n >> a >> b >> c;
	vector<string> v(n);
	queue<int> q[3];
	//cout << "COE\n";
	FOR(i, n){
		cin >> v[i];
		if(v[i] == "AC")
			q[0].push(i);
		else if(v[i] == "AB")
			q[1].push(i);
		else
			q[2].push(i);
	}
	FOR(i, 3)
		q[i].push(MOD);
	bool ok = true;
	string ans;
	FOR(i, n){
		string s = v[i];
		if(a+b+c == 2){
			if(s == "AC"){
				if(c == 0){
					a--; c++;
					ans.PB('C');
				}else if(a == 0){
					a++; c--;
					ans.PB('A');
				}else if(q[1].front() < q[2].front()){
					a++; c--;
					ans.PB('A');
				}else{
					a--; c++;
					ans.PB('C');
				}
				q[0].pop();
			}else if(s == "AB"){
				if(a == 0){
					b--; a++;
					ans.PB('A');
				}else if(b == 0){
					b++; a--;
					ans.PB('B');
				}else if(q[0].front() < q[2].front()){
					a++; b--;
					ans.PB('A');
				}else{
					a--; b++;
					ans.PB('B');
				}
				q[1].pop();
			}else{
				if(c == 0){
					b--; c++;
					ans.PB('C');
				}else if(b == 0){
					b++; c--;
					ans.PB('B');
				}else if(q[0].front() < q[1].front()){
					c++; b--;
					ans.PB('C');
				}else{
					c--; b++;
					ans.PB('B');
				}
				q[2].pop();
			}
		}else if(s == "AC"){
			if(a < c){
				a++; c--;
				ans.PB('A');
			}else{
				a--; c++;
				ans.PB('C');
			}
			q[0].pop();
		}else if(s == "AB"){
			if(a < b){
				a++; b--;
				ans.PB('A');
			}else{
				a--; b++;
				ans.PB('B');
			}
			q[1].pop();
		}else{
			if(b < c){
				b++; c--;
				ans.PB('B');
			}else{
				b--; c++;
				ans.PB('C');
			}
			q[2].pop();
		}
		if(a < 0 || b < 0 || c < 0)
			ok = false;
	}

	if(ok){
		cout << "Yes\n";
		for(char c : ans)
			cout << c << '\n';
	}else
		cout << "No\n";

 	return 0;
}

Measured memory_bytes: 7128
#include <iostream>
#include <vector>

int main(){
	int n, m;
	std::cin >> n >> m;

	std::vector<int> city(n, 0);
	for(int i = 0; i < m; ++i){
		int a, b;
		std::cin >> a >> b;
		--a;
		--b;
		++city.at(a);
		++city.at(b);
	}

	for(int d : city){
		std::cout << d << std::endl;
	}

	return 0;
}


	


Measured memory_bytes: 256
// D - Div Game
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 素数と個数を求める
vector<pair<ll,ll>> factorize(ll n){
  vector<pair<ll,ll>> res;
  for(ll i=2L; i*i<=n; ++i){
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1L);
  return res;
}

int main(){
	ll N; cin>>N;
	vector<pair<ll,ll>> P = factorize(N);
	ll ans = 0;
	for(auto x:P)
		for(ll p=x.first, c=x.second, pi=p, i=1; i<=c; i++, pi*=p){
			if(N%pi) continue;
			N /= pi;
			ans++;
		}
	cout<< ans <<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int Binary_Search(ll first,ll last,vector<ll>v,ll search_value)
{
    int pos=-1;
    while(first<=last)
    {
        ll mid=first+((last-first)/2);
        if(v[mid]==search_value)
        {
            pos=mid;
            break;
        }
        else if(search_value>v[mid])
        {
            first=mid+1;
        }
        else
        {
            last=mid-1;
        }
    }
    return pos;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    {
        return a;
    }
    else
    {
        return gcd(b,a%b);
    }
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int c=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		Set<String> a = new HashSet();

		for(int i = 0; i < N;i++) {
			a.add(sc.next());
		}
		System.out.println(a.size());


	}
}

Measured memory_bytes: 76032
"use strict";

const main = (input) => {
  const args = input.trim().split("\n");
  const n = to_num(args[0].split(" ")[0]);
  const m = to_num(args[0].split(" ")[1]);
  let R = [];
  let L = [];
  args.map((line, index) => {
    if (index === 0) return;
    L.push(to_num(line.split(" ")[0]));
    R.push(to_num(line.split(" ")[1]));
  });

  let maxL = -1000;
  let minR = 1000000;
  for (let i = 0; i < m; i++) {
    maxL = Math.max(maxL, L[i]);
    minR = Math.min(minR, R[i]);
  }
  console.log(Math.max(0, minR - maxL + 1));
};

const to_num = (str: string): string => {
  return parseInt(str, 10);
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 53632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll> m;
	ll a,b,c;
	ll N,Q;
	ll all = 0;
	cin>>N;

	vector<ll> ans(N);
	for(ll i=0;i<N;i++){
		cin>>a;m[a]++;
		all+=a;
	}
	cin>>Q;
	for(ll i=0;i<Q;i++){
		cin>>b>>c;
		all=(c-b)*m[b]+all;
		m[c]+=m[b];
		m[b]=0;
		cout<<all<<endl;
	}
}

Measured memory_bytes: 9992
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rept(i,k,n) for(long long i = (k); i < (long long)(n); i++)
#define All(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Rsort(v) sort(v.begin(),v.end(),[](auto a, auto b) { return a > b; })
#define Reverse(v) reverse(v.begin(),v.end())
#define MAX 1000000007
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}

int main(){
    ll n,x,m,s=0;
    cin>>n>>x>>m;
    vector<ll> sum(m,0);
    map<ll,ll> mp;
    rep(i,n){
        sum[i+1]=sum[i]+x;
        if(mp.count(x)){
            ll k = mp[x];
            ll c = i-k;
            ll h = (n-k)%c;
            ll ans = sum[k]+(sum[i]-sum[k])*((n-k)/c)+sum[k+h]-sum[k];
            cout<<ans<<endl;
            return 0;
        }
        mp[x]=i;

        x=x*x%m;
        
    }
    cout<<sum[n]<<endl;
    return 0;
}

Measured memory_bytes: 7060
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    class combination():
        # 素数のmod取るときのみ　速い
        def __init__(self, n, mod):
            self.n = n
            self.mod = mod
            self.fac = [1] * (n + 1)
            self.inv = [1] * (n + 1)
            for j in range(1, n + 1):
                self.fac[j] = self.fac[j - 1] * j % mod

            self.inv[n] = pow(self.fac[n], mod - 2, mod)
            for j in range(n - 1, -1, -1):
                self.inv[j] = self.inv[j + 1] * (j + 1) % mod

        def comb(self, n, r):
            if r > n or n < 0 or r < 0:
                return 0
            return self.fac[n] * self.inv[n - r] * self.inv[r] % self.mod
    N = I()
    A = LI()
    C = combination(N,mod)
    ans = 0
    cnt = 0
    for i in range(N):
        cnt += C.fac[N]*pow(i+1,mod-2,mod)
        cnt %= mod
        #print(cnt)
    #print(cnt)
    ans += cnt*A[0]
    for i in range(1,N):
        cnt = cnt + C.fac[N]*pow(i+1,mod-2,mod) - C.fac[N]*pow(N-i+1,mod-2,mod)
        cnt += mod
        cnt %= mod
        a = A[i]
        ans += cnt*a
        ans %= mod
        #print(cnt)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 22012
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b;
  cin >> a >> b;
  string A,B;
  rep(i,b){
    A+=to_string(a);
  }
  rep(i,a){
    B+=to_string(b);
  }
  cout << ((A>B)?B:A) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)


int32_t main() { 
    boost;
    
    int x,y,p,q,r;
    cin>>x>>y>>p>>q>>r;
    vector<pair<int,int>>v;
    int tmp;
    for(int i=0;i<p;i++){
        cin>>tmp;
        v.push_back({tmp,1});
    }

    for(int i=0;i<q;i++){
        cin>>tmp;
        v.push_back({tmp,2});
    }

    for(int i=0;i<r;i++){
        cin>>tmp;
        v.push_back({tmp,3});
    }
    sort(v.begin(),v.end(),greater<>());
    int ans=0,cnt=0;
    int xx=x,yy=y;
    for(int i=0;i<v.size();i++){
        if(v[i].ss==1 && x>0){
            ans+=v[i].ff;
            x--;
            cnt++;
        }
        else if(v[i].ss==2 && y>0){
            ans+=v[i].ff;
            y--;
            cnt++;
        }
        else if(v[i].ss==3){
            ans+=v[i].ff;
            cnt++;
        }
        if(cnt  == xx+yy)
            break;
    }
    cout<<ans<<endl;
}	

Measured memory_bytes: 10476
#include<bits/stdc++.h>
using namespace std;
string S[5000],T[5000],V[5000],A,B,C;int a[5000],b[5000],n,m,dist[5000];
vector<string>U;vector<pair<int,int>>x[500];
int dfs(int s,int g){
	for(int i=0;i<5000;i++)dist[i]=1<<30;
	dist[s]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<x[j].size();k++){
				dist[x[j][k].first]=min(dist[x[j][k].first],dist[j]+x[j][k].second);
			}
		}
	}
	return dist[g];
}
int main(){
	while(true){
		cin>>n>>m;for(int i=0;i<500;i++)x[i].clear();
		if(n==0){break;}U.clear();cin>>A>>B>>C;
		for(int i=0;i<m;i++){
			cin>>S[i]>>T[i]>>a[i]>>b[i];
			U.push_back(S[i]);U.push_back(T[i]);
		}
		sort(U.begin(),U.end());V[0]=U[0];int cnt=1,G,H,I;
		for(int i=1;i<U.size();i++){
			if(U[i]!=U[i-1]){V[cnt]=U[i];cnt++;}
		}
		for(int i=0;i<cnt;i++){
			if(A==V[i])G=i;
			if(B==V[i])H=i;
			if(C==V[i])I=i;
		}
		for(int i=0;i<m;i++){
			int s1=0,t1=0;
			for(int j=0;j<cnt;j++){
				if(S[i]==V[j])s1=j;
				if(T[i]==V[j])t1=j;
			}
			x[s1].push_back(make_pair(t1,a[i]/40+b[i]));
			x[t1].push_back(make_pair(s1,a[i]/40+b[i]));
		}
		cout<<dfs(G,H)+dfs(H,I)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3900
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t L, R;
  cin >> L >> R;
  int64_t result = kInf;
  if ((R - L >= 2019) || (L % 2019) >= (R % 2019)) {
    result = 0;
  } else {
    R %= 2019;
    L %= 2019;
    for (int64_t i = L; i <= R; ++i) {
      for (int64_t j = i + 1; j <= R; ++j) {
        result = min(result, ((i * j) % 2019));
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111
 
typedef long long ll;
typedef long double ld;
 
char str[maxn];
int arr[33];
 
int main(){
	scanf("%s", str);
	int n = strlen(str);
	for(int i = 0; i < n; i++)
		arr[str[i] - 'a']++;

	ll ans = 1LL * n * (n + 1LL) / 2LL + 1LL;

	for(int i = 0; i < 33; i++)
		ans -= 1LL * arr[i] * (arr[i] + 1) / 2LL;

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<utility>

using namespace std;

int main(){

    while(1){
        int n;
        cin >> n;
        if(n==0){
            break;
        }
        string AL="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        vector<string> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        vector<pair<int,string>> c(26);
        for(int i=0;i<26;i++){
            c[i].first=0;
            c[i].second=AL[i];
        }
        bool f=true;
        for(int i=0;i<a.size();i++){
            string t=a[i];
            c[t[0]-'A'].first++;
            vector<pair<int,string>> tt(c);
            sort(tt.begin(),tt.end(),greater<>());
            if(tt[0].first>tt[1].first+(n-i-1)){
                cout << tt[0].second << " " << i+1 << endl;
                f=false;
                break;
            }
        }
        if(f){
            cout << "TIE" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3080