akhauriyash/Code-Regression huggingface dataset:
module Main where
import Data.Maybe
import Data.List(foldl', union)

main = interact $ printer . solver . parser
int = read :: String -> Int
count a bs = length $ filter (==a) bs
split n ls = map (take n) $ takeWhile (/=[]) $ iterate (drop n) ls

printer = unlines . (:[]) . show
parser input = (n, m, edges)
  where
    (n:m:abs) = map int $ words input
    edges = map (\[x,y]->(x,y)) $ split 2 abs


nextNode :: Int -> [(Int,Int)] -> [Int]
nextNode p edges = map (\(a,b)->if p==a then b else a) $ filter (\(a,b)->p==a||p==b) edges

neighbours :: Int -> [(Int,Int)] -> [(Int, [Int])]
neighbours n edges = [(p,nextNode p edges)|p<-[1..n]]

convergence (n1:n2:ns) = if n1==n2 then n1 else convergence (n2:ns)

solver :: (Int, Int, [(Int,Int)]) -> Int
solver (n, m, edges)
  = (\x -> m - x) $ count True $
    do target <- edges
       let edge2 = filter (/=target) edges
       let nei = neighbours n edge2
       let func xs = foldl' union xs $ map (\x -> fromJust $ lookup x nei) xs
       let g = convergence $ iterate func [fst target]
       return (elem (snd target) g)
      


Measured memory_bytes: 1404
i = 0
j = 0
k = 0

w = ""
for s in input():
    j += 1

    if s == "S":
        k += 1

    if s == "S" and i > 0 and j == 2 and w != "R":
        i -= 1

    if s == "R" and (w == "R" or w == ""):
        i += 1
    elif s == "R" and w != s:
        i += 1    
    
    if w == "S":
        i = 1
    
    w = s

if k == 3:
    i = 0

print(i)

Measured memory_bytes: 8800
n,k = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_f)
p_kitai = []
for i in 0..n-1
  p_kitai[i] = (p[i].to_f * (p[i].to_f + 1.0) / 2.0) / p[i].to_f
end

max = 0.0
kitaichi = 0.0
for i in 0..k-1
  kitaichi += p_kitai[i]
end
max = kitaichi
for i in k..n-1
  kitaichi = kitaichi + p_kitai[i] - p_kitai[i-k]
   if max < kitaichi
     max = kitaichi
   end
 end
puts max

Measured memory_bytes: 17612
#include <stdio.h>

int dis(int x,int x1,int y, int y1)
{
    int sum;
    if(x>y)         sum = sum + x - y;
    else            sum = sum - x + y;
    if(x1>y1)       sum = sum + x1 - y1;
    else            sum = sum - x1 + y1;
    return sum;
}

int main(void) {
	int n,m,i,j,s,min,k;
	scanf("%d %d",&n,&m);
	int a[n],b[n],c[m],d[m];
	for(i=0;i<n;++i)    scanf("%d %d",&a[i],&b[i]);
	for(i=0;i<m;++i)    scanf("%d %d",&c[i],&d[i]);
	for(i=0;i<n;++i){
	    j=0;
	    min = dis(a[i],b[i],c[j],d[j]);
	    k=1;
	    for(j=1;j<m;++j){
	        s = dis(a[i],b[i],c[j],d[j]); 
	        if(s<min){
	            min = s; 
	            k = j+1;
	        }
	    }
	    printf("%d\n",k);
	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

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

    vector <int> A(N);
    vector <int> B(N);
    

    for (int i=0;i<N;i++){
        cin >> A[i] >> B[i];

    }

    ll dp[H+1]={10000000002};
    dp[0] = 0;

    for(int i=1;i<=H;i++){
        dp[i] = 10000000002;
        for(int j=0;j<N;j++){
            
            int id = max(0,i-A[j]);

            dp[i] = min(dp[id]+B[j],dp[i]);
            // cout << dp[i] <<endl;


        }
    }

    cout << dp[H];





}

Measured memory_bytes: 384
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    cin >> n;
    map<int, int> table;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        table[a]++;
    }
    int count = 0;
    for(auto itr = table.begin(); itr != table.end(); ++itr) {
        if (itr->first < itr->second) {
            count += (itr->second - itr->first);
        } else if (itr->first > itr->second) {
            count += itr->second;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 4736
import java.util.*;

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

        int numA = cha.indexOf('A');
        int numZ = cha.lastIndexOf('Z');
        
        int ans = numZ - numA + 1;

        System.out.println(ans);
	}
}

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

char x[3];
int main() {
    int n;
    int i, len;
    scanf("%s", x);
    
    len = strlen(x);
    for (i = 0; i < len; i++) {
        if (x[i] == '1') cout << 9;
        else if (x[i] == '9') cout << 1;
        else cout << x[i];
   }
   
   cout << endl;
   
   return 0;    
}

Measured memory_bytes: 764
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int k,a,b;
	cin>>k;
	cin>>a>>b;
	if(a%k==0||k*(a/k+1)<=b)
	{
		cout<<"OK"<<endl;
	}
	else
	{
		cout<<"NG"<<endl;
	}
	return 0;
}


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

// #, .で構成されるSについて、パターン#.が無くなるように置換する最小回数
// N <= 2*10^5, len(S) = N

int main(){
	int N;
	string pattern;
	int count = 2*100000;

	cin >> N >> pattern;

	int c_black[N+1];
	int c_white[N+1];
	c_black[0] = 0;
	c_white[0] = 0;

	for (int i = 0; i < N; i++){
		if (pattern[i] == '#'){
			c_black[i+1] = c_black[i] + 1;
			c_white[i+1] = c_white[i];
		}else if (pattern[i] == '.'){
			c_black[i+1] = c_black[i];
			c_white[i+1] = c_white[i] + 1;
		}else{
			cout << "Invalid Input" << endl;
		}
	}

	for (int j = 0; j < N+1; j++){
		count = min(count, c_black[j] + c_white[N] - c_white[j]);
	}
	cout << count << endl;
}

Measured memory_bytes: 2180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc076/tasks/abc076_c

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

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string min = "~";
    REP(i, S.length() - T.length() + 1) {
        string sub = S.substr(i, T.length());

        bool can = true;
        REP(j, sub.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }
        if (can) {
            string P = S;
            REP(j, T.length()) {
                P[i+j] = T[j];
            }
            REP(j, P.length()) {
                if (P[j] == '?') P[j] = 'a';
            }
            min = std::min(P, min);
        }
    }

    if (min == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << min << "\n";
    }

    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto && e : a) cin >> e;
  for (int i = k; i < n; ++i) {
    cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
  }
}


Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    if(x == 0)
    {
        cout << "1\n";
    }
    else
    {
        cout << "0\n";
    }
    return 0;
}


Measured memory_bytes: 3612
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>
#include <cmath>


int main(void) {
    
    using namespace std;
    
    int N;
    
    cin >> N;
    
    char a[N], b[N];
    
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    for(int i=0; i<N; i++){
        cin >> b[i];
    }
    
    for(int i=0; i<N; i++){
        cout << a[i];
        cout << b[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endll "\n"
#define show(a) cerr<<""#a""<<" is "<<a<<endll;
int caseno=0;
#define print_case cout<<"Case "<<++caseno<<": ";
#define fout freopen("output.txt","w",stdout);
#define fin freopen("input.txt","r",stdin);
#define srt(v) sort(v.begin(),v.end());
#define greatersrt(v) sort(v.begin(),v.end(),greater<ll>())
#define pb push_back
#define mp make_pair
#define here cerr<<"here\n";
#define PI acos(-1.0)
#define ll long long
#define ld long double
#define reto exit(0);
#define sspace <<" "<<
#define print(arr,xx) for(int i=1;i<xx;i++)cerr<<arr[i]<<" \n"[i==n];
bool sortbysec(pair<int,int>a,pair<int,int>b){return a.second>b.second;}
ll gc(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lc(ll a,ll b){return a/gc(a,b)*b;}
const int primemod=1e9+7;
const ld eps=1e-9;
#define inl(x) scanf("%lld",&x)
#define in(x) scanf("%d",&x)
#define pii pair<int,int>
/**Code Goes Here**/
#define maxsize 200000+9
#define rshuffle(r...)rshuffle(r,[](int _){return rand()%_;})
int arr[maxsize],dp[maxsize];
int main()
{
    int n,k;
    in(n),in(k);
    for(int i=1;i<=n;i++){
        in(arr[i]);
        dp[i]=INT_MAX;
    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
        for(int j=max(1,i-k);j<i;j++)
        {
               // print(dp,n+1);

            dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
    }
    printf("%d\n",dp[n]);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int cnt[200002];

int main()
{
    int n,i,a;
    scanf("%d",&n);
    for(i=1; i<n; i++)
    {
        scanf("%d",&a);
        cnt[a]++;
    }
    for(i=1; i<=n; i++)printf("%d\n",cnt[i]);
    return 0;
}


Measured memory_bytes: 4520
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
class priorityQueue{
  constructor(){
    this.heap = [];
  }
  push(x){
    var h = this.heap, i = h.length++, j;
    while(i){
      j = i-1 >> 1;
      if(h[j][0] <= x[0])break;
      h[i] = h[j], i = j;
    }
    h[i] = x;
  }
  pop(){
    var h = this.heap, x = h.pop(), l = h.length;
    if(l === 0)return x;
    var r = h[0], i = 0, k = l >> 1, j;
    while (i < k) {
      j = i + i + 1;
      if(j < l-1 && h[j+1][0] < h[j][0])++j;
      if(x[0] <= h[j][0])break;
      h[i] = h[j], i = j;
    }
    h[i] = x;
    return r;
  }
  get size(){return this.heap.length;}
  get top(){return this.heap[0];}
}
class dijkstra{
  constructor(n){
    this.graph = Array(n).fill().map(a=>[]);
  }
  add(from,to,cost){
    this.graph[from].push(to,cost);
  }
  solve(start,goal){
    const INF = 4e9;
    const g = this.graph, n = g.length;
    const cost = Array(n).fill(INF);
    const pq = new priorityQueue();
    cost[start] = 0;
    pq.push([0,start]);
    while(pq.size){
      var p = pq.pop();
      var v = p[1];
      if(cost[v] < p[0])continue;
      if(v === goal)return cost[v];
      for(var i = 0; i < g[v].length; i+=2){
        var V = g[v][i];
        var c = cost[v] + g[v][i+1];
        if(c < cost[V]){
          cost[V] = c;
          pq.push([c,V]);
        }
      }
    }
    return -1;
  }
}
console.log(main());
function main(){
  var xs = o.a();
  var ys = o.a();
  var xt = o.a();
  var yt = o.a();
  var n = o.a();
  var g = o.m(n);
  var di = new dijkstra(n+2);
  for(var i = 0; i < n; i++)for(var j = i+1; j < n; j++){
    var x = g[i][0]-g[j][0];
    var y = g[i][1]-g[j][1];
    var dist = Math.sqrt(x*x+y*y);
    dist -= g[i][2] + g[j][2];
    if(dist < 0)dist = 0;
    di.add(i,j,dist);
    di.add(j,i,dist);
  }
  for(var i = 0; i < n; i++){
    x = g[i][0]-xs;
    y = g[i][1]-ys;
    dist = Math.sqrt(x*x+y*y);
    dist -= g[i][2];
    if(dist < 0)dist = 0;
    di.add(n,i,dist);
    x = g[i][0]-xt;
    y = g[i][1]-yt;
    dist = Math.sqrt(x*x+y*y);
    dist -= g[i][2];
    if(dist < 0)dist = 0;
    di.add(i,n+1,dist);
    x = xs-xt;
    y = ys-yt;
    dist = Math.sqrt(x*x+y*y);
    di.add(n,n+1,dist);
  }
  return di.solve(n,n+1);
}

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

int main()
{
	long long X, Y;
	cin >> X >> Y;
	if (X % Y == 0){
		cout << -1;
	}else{
		long long max = 1000000000000000000;
		long long k = -1;
		for (long long i = X; i <= max; i=i+X){
	    	 long long j = (i % Y != 0) ? i : -1;
		 	k = j > k ? j : k;
		 	if (k != -1) break;
		 	}
		cout << k;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    int d[K], A[K][N];
    for (int i = 0; i < K;i++) {
        scanf("%d", &d[i]);
        for (int j = 0; j < d[i]; j++) {
            scanf("%d", &A[i][j]);
        }
    }
    
    int s[N];
    for (int i = 0; i < N; i++) {
        s[i] = 1;
    }
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < d[i]; j++) {
            s[A[i][j]-1] = 0;
        }
    }
    int x = 0;
    for (int i = 0; i < N; i++) {
        if (s[i]) {
            x++;
        }
    }

    printf("%d\n", x);
    return 0;
}


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

char blank = ' ';
void print_array(int* data, int length) {
    for (int i = 0; i < length; ++i) {
        if (i == length - 1) {
            cout << data[i] << endl;
        } else {
            cout << data[i] << blank;
        }
    }
}

int main() {
    int data_length = 0;
    cin >> data_length;
    int* data = new int[data_length];

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

    print_array(data, data_length);

    for (int i = 1; i < data_length; ++i) {
        int k = i;
        int j = i;
        while (j >= 0 && data[j] < data[j - 1]) {
            std::swap(data[j], data[j - 1]);
            --j;
        }
        print_array(data, data_length);
    }


    delete[] data;
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
int ctoi(char c) {return c-'0';}

const int mxn=1e5+5;
ll dp[mxn][3];
int a[mxn][3];
map<int,vi> m;

void setup() {
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  m[0].pb(1);
  m[0].pb(2);
  m[1].pb(0);
  m[1].pb(2);
  m[2].pb(0);
  m[2].pb(1);
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int N;
cin>>N;
forn(i,N) {
  forn(j,3) {
    cin>>a[i][j];
  }
}
setup();
for(int i=1;i<N;i++) {
  forn(j,3) {
    for(auto& d: m[j]) {
      dp[i][j]=max(dp[i][j],a[i][j]+dp[i-1][d]);
    }
  }
}
ll ans=0;
forn(i,3) {
  ans=max(ans,dp[N-1][i]);
}
cout<<ans<<endl;
return 0;
}


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

const int MAX_N = 100000;
typedef long long ll;

int main() {
	int N, M;
	std::pair<ll, int> data[MAX_N];

	std::cin >> N >> M;
	for(int i = 0; i < N; ++i) {
		ll a;
		int b;
		std::cin >> a >> b;
		data[i] = std::make_pair(a, b);
	}
	std::sort(data, data + N);

	int cnt = 0;
	ll ans = 0;
	for(int i = 0; i < N; ++i) {
		if(cnt == M) break;
		int purchase = std::min(data[i].second, M - cnt);
		ans += data[i].first * purchase;
		cnt += purchase;
	}

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

 }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}
 
 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) r = (r * a) % mod;
		a = (a * a) % mod;
		n >>= 1;
	}
	return r;
}
 
void solve(){
	int n;
	cin >> n;
	unordered_map<string, int> m;
	rep(i, n) {
		string s;
		cin >> s;
		m[s]++;
	}
	cout << m.size();
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
	//cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 17704
#include <bits/stdc++.h>
#include <complex>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define int long long
#define INF 1e9
#define MOD 1e9 + 7
using namespace std;

template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

using P = complex<double>;
const double PI = acos(-1);
const double EPS = 1e-9;
// P p(a,b)=a+bi -> 点p(a,b)
namespace std {
  bool operator<(const P &a, const P &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); }
  bool operator==(const P &a, const P &b) { return a.real() == b.real() && a.imag() == b.imag(); }
} // namespace std

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a);
    push_back(b);
  }
};
//内積
double dot(P a, P b) { return real(conj(a) * b); }
//外戚
double cross(P a, P b) { return imag(conj(a) * b); }

int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1; // counter clockwise
  if (cross(b, c) < 0) return -1; // clockwise
  if (dot(b, c) < 0) return +2; // c--a--b on line
  if (norm(b) < norm(c)) return -2; // a--b--c on line
  return 0;
}
signed main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    int flag = ccw(P(a, b), P(c, d), P(x, y));
    if (flag == 1)
      cout << "COUNTER_CLOCKWISE" << endl;
    else if (flag == -1)
      cout << "CLOCKWISE" << endl;
    else if (flag == 2)
      cout << "ONLINE_BACK" << endl;
    else if (flag == -2)
      cout << "ONLINE_FRONT" << endl;
    else
      cout << "ON_SEGMENT" << endl;
  }
  return 0;
}



Measured memory_bytes: 3148
#Sが長いほう
N = int(input())
A = list(map(int, input().split()))

cnt = 0
sumall = sum(A)
#print(sumall)
for i in range(N-1):
  sumall -= A[i]
  cnt += (A[i] * sumall )%(10**9+7)
print(cnt%(10**9+7))

Measured memory_bytes: 31576
#include <stdio.h>
#define N 100

void trace(int A[], int n) {
	int i;
	for (i = 0; i < n; i++) {
		printf("%d", A[i]);
		if (i + 1 < n) printf(" ");
	}
	printf("\n");
}

void insertionSort(int A[], int n) {
	int i, j, v;

	for (i = 1; i < n; i++) {
		v = A[i];
		j = i - 1;

		while (j >= 0 && A[j]>v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, n);
	}
}


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

	trace(A, n);
	insertionSort(A, n);

	return 0;
}

Measured memory_bytes: 2732
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
  int a, b, c;
  cin >> a >> b >> c;
  int t = a;
  if (t < b)
    t = b;
  if (t < c)
    t = c;
  if (2 * t == a + b + c)
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
  return 0;
};

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

int main() {
  int N, C;
  cin >> N >> C;
  vector<vector<P>> prog(C);
  rep(i,N) {
    int s, t, ch;
    cin >> s >> t >> ch;
    --ch;  // 0-indexed
    prog[ch].push_back(P(s, t));
  }

  vector<P> prog2;
  rep(i,C) {
    sort(prog[i].begin(), prog[i].end());
    prog[i].push_back(P(0, 0));
    P pre = P(0, 0);

    for (auto p : prog[i]) {
      if (pre.second == p.first) {
        pre.second = p.second;
      } else {
        if (pre.first != 0) prog2.push_back(pre);
        pre = p;
      }
    }
  }

  sort(prog2.begin(), prog2.end());
  priority_queue<int, vector<int>, greater<int>> prog_end;
  int ans = 0;

  for (auto p : prog2) {
    while (prog_end.size() != 0) {
      if (prog_end.top() < p.first) {
        prog_end.pop();
      } else break;
    }
    prog_end.push(p.second);
    if (ans < prog_end.size()) {
      ans = prog_end.size();
    }
  }

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


Measured memory_bytes: 2552
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	string S,T,U;
	ll A,B;
	cin >> S >> T >> A >> B >> U;
	if (S==U) {
		cout << A-1 << " " << B;
	} else {
		cout << A << " " << B-1;
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

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

long long MOD=1000000007LL;

long long dp[101][64000];

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

	int rN=sqrt(N);
	vector<long long> init;
	int c=0;
	for(int i=1;i<=rN;i++){
		if(i!=rN || i*(i+1)<=N)init.push_back(N-N/(i+1)-c);
		c+=N-N/(i+1)-c;
	}
	for(int i=1;i<=rN;i++)init.push_back(1);
	reverse(init.begin(),init.end());
	
	int M=init.size();
	for(int i=0;i<M;i++)dp[0][i+1]=init[i];
	
	for(int i=0;i<K-1;i++){
		vector<long long> sum(M+1,0);
		for(int j=1;j<=M;j++)sum[j]=sum[j-1]+dp[i][j];
		for(auto &k:sum)k%=MOD;
		for(int j=1;j<=M;j++)dp[i+1][j]=sum[M-j+1]*init[j-1];
	}
	
	long long ans=0;
	for(int j=1;j<=M;j++)ans+=dp[K-1][j];
	cout << ans%MOD << endl;
	
	/*for(int i=0;i<K;i++){
		for(int j=0;j<=M;j++)cout << dp[i][j] << " ";
		cout << endl;
	}*/
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n), a(n);
  for(int i=1; i <= n; i++) a[i-1] = i;
  for(int i=0; i < n; i++) cin >> p[i];
  for(int i=0; i < n; i++) cin >> q[i];

  sort(a.begin(), a.end());

  int pp, qq;
  int c = 0;
  do {
    c++;
    bool find = true;
    for(int i=0; i < a.size(); i++) {
      if(a[i] != p[i]){find = false; break;}
    }
    if(find) pp = c;

    find = true;
    for(int i=0; i < a.size(); i++) {
      if(a[i] != q[i]){find = false; break;}
    }
    if(find) qq = c;
  }while(next_permutation(a.begin(), a.end()));

  cout << abs(pp-qq) << endl;
}


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

int main(){

	map<int ,bool> memo;

	int N;
	cin>>N;
	
	int cnt=0;
	
	for(int i=0;i<N;i++){
		int p[3];
		cin>>p[0]>>p[1]>>p[2];
		
		sort(p,p+3);

		int k=((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
		
		if(memo.find(k)!=memo.end()){
			cnt++;
		}else{
			memo[k]=true;
		}

	}

	cout<<cnt<<endl;
		
	return 0;
		
	}

Measured memory_bytes: 3180
s = str(input())
n = int(input())

cand = [str(s[0])]
for i in range(len(s)):
    if len(cand) == n and s[i] > cand[-1]:
        continue
    for j in range(i, len(s)):
        tmp = s[i:j+1]
        #print(i,j, tmp, cand)
        if len(cand) == n and tmp > cand[-1]:
            break
        if tmp in cand:
            continue
        cand += [tmp]
        #cand = sorted(cand)
        cand.sort()
        if len(cand) > n:
            cand.pop()


print(cand.pop())


Measured memory_bytes: 3064
import math


def resolve():
    import sys
    input = sys.stdin.readline
    row1 = [int(x) for x in input().rstrip().split(" ")]
    h = row1[0]
    w = row1[1]

    if h == 1 or w == 1:
        print(1)
        return

    ans = (h-(h%2))*(w-(w%2))/2
    ans += (h%2)*(w-(w%2))/2
    ans += (w%2)*(h-(h%2))/2
    ans += (w%2)*(h%2)

    print(int(ans))


if __name__ == "__main__":
    resolve()


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

int main() {
  int n; cin >> n;
  vector<int> b(n-1);
  rep(i,n-1) cin >> b[i];

  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    ans += min(b[i], b[i-1]);
  }
  ans += b[0];
  ans += b[n-2];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
listS = [input() for i in range(N)]
ans = "Yes"
for j in range(1, N):
    if listS.count(listS[j]) == 1 and listS[j - 1][-1] == listS[j][0]:
        continue
    else:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 3060
n = int(input())
s = input()
r = []
g = []
b = []
for i in range(n):
	if s[i] == "R":
		r.append(i)
	elif s[i] == "G":
		g.append(i)
	else:
		b.append(i)
count = 0
unchi = set(b)
for i in r:
	for j in g:
		u = abs(i-j)
		count += [0,1][(max(i,j)+u) in unchi] + [0,1][(min(i,j)-u) in unchi] + [0,1][u%2 == 0 and (i+j)//2 in unchi]
print(len(r)*len(g)*len(b)-count)

Measured memory_bytes: 68768
#include<stdio.h>
#include<string>
using namespace std;
int n;
string s1,s2;
bool ff;
string a[2]={".","#"};
bool tri(string s1,string s2){
	puts(s1.c_str());
	puts(s2.c_str());
	fflush(stdout);
	char s[9];
	scanf("%s",s);
	if(*s=='e')exit(0);
	return *s=='T';
}
int main(){
	scanf("%d",&n);
	ff = true;
	while(1){
		if(ff){
			ff = false;
			for(int i=0; i<4; i++)
				if(tri(s1 + a[i/2], s2 + a[i%2])){
					s1 += a[i/2];
					s2 += a[i%2];
					ff = true;
					break;
				}
		}else{
			for(int i=0; i<4; i++)
				if(tri(a[i/2] + s1, a[i%2] + s2)){
					s1 = a[i/2] + s1;
					s2 = a[i%2] + s2;
					break;
				}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(void){
	int i,j,k,n,judge ;
	int prime_array[1000000] = {2,3};
	while(scanf("%d",&n)==1){
		if (n<=1) {
			printf("%d\n",0);
		} else if (n ==2){
			printf("%d\n",1);
		} else{
			k = 2;
			for(j=5;j<=n;j+=2){
				judge = 1;
				for(i=0;prime_array[i]*prime_array[i]<=j;i++){
					if(j%prime_array[i]==0){
						judge = 0;
						break;
					}
				}
				if(judge){
					prime_array[k++] = j;
					}
			}
		printf("%d\n",k);
	}
	}
	return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    ll n,k;
    cin >> n >> k;
    vi a(k);
    vi b(k);
    REP(i, k){
        cin >> a[i] >> b[i];
    }
    SORT(a);
    SORT(b);
    int ans = max(0, b[0]-a[k-1]+1);
    COUT(ans);
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N, K;
    cin >> N >> K;
    if(K <= N) {
        LL Q = N%K;
        N = min(Q, N - Q);
    }
    cout << min(N, K - N) << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    
    N = int(input())
    D,K = map(int,input().split())
    conSumeList = [int(input()) for _ in range(N)]
    tmp = 0
    ans = 0

    for i in range(N):
        ans += 1
        tmp += conSumeList[i]
        while(True):
            if tmp+1 <= D:
                ans += 1
                tmp += conSumeList[i]
            else:
                break
        tmp = 0
    
    print(ans+K)




    


if __name__== "__main__":
    main() 











Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int i=1,c=0;
	long long int a,b;
	scanf("%lld %lld",&a,&b);
	while(i){
		if(a<=b){
			c=c+1;
		}
		if(a>b){
			i=0;
		}
		a=a*2;
	}
	printf("%d",c);
	return 0;
}

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

int main(){
    long long a;
    string b;
    cin >>a >>b;
    long long num=0;
    for(int i=0;i<b.size();i++){
        if(b[i]=='.'){
            continue;
        }else{
            num += b[i]-'0';
            num*=10;
        }
    }
    num/=10;
    cout << (a*num)/100 << endl;;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using  namespace std;
long long factorial[MAX] = {0}, finverse[MAX] = {0},
        inverse[MAX] = {0};

void smodfact() {
    factorial[0] = factorial[1] = 1;
    finverse[0] = finverse[1] = 1;
    inverse[1] = 1;
    for(int i = 2; i < MAX; ++i) {
        factorial[i] = factorial[i - 1] * i % N;
        inverse[i] = N - (inverse[N % i] * (N / i)) % N;
        finverse[i] = finverse[i - 1] * inverse[i] % N;
    }
}

long long calccomb(long long n, long long k) {
    if(n == k && n == 0) return 1;
    if(n < 0 || k < 0 || n < k) return 0;
    return factorial[n] * finverse[k] % N * finverse[n - k] %
           N;
}

long long b,w,n;
long long dpb[300005]={0},dpw[300005]={0};

void solve();

int main(){
    smodfact();
    cin >> b >> w;
    n = b + w;
    solve();
    return 0;
}

void solve(){
    long long bin = 1;
    for(int i = 0;i < n;++i){
        long long now = 1;
        now += (dpw[i] - dpb[i] + N) % N;
        now %= N;
        bin *= inverse[2];
        bin %= N;
        dpb[i+1] = (dpb[i] + bin * calccomb(i,b-1) % N) % N;
        dpw[i+1] = (dpw[i] + bin * calccomb(i,w-1) % N) % N;
        cout << now * inverse[2] % N << endl;
    }
}

Measured memory_bytes: 18176
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a , b, c;
	cin >> a >> b >> c;

    cout << min(a+b, min(b+c, c+a)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, q;
    cin >> n >> k >> q;
    vii p(n, 0);
    rep(i,q){
        int a;
        cin >> a;
        p[a - 1]++;
    }
    rep(i,n){
        if (k-q+p[i]>0){
            cout << "Yes" << ENDL;
        }
        else{
            cout << "No" << ENDL;
        }
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int n;
	cin>>n;
	int maxPos = 0;
	vector<int> v(n), c(n);
	REP(i,n)
		cin>>v[i];
	REP(i,n)
		cin>>c[i];
	for(int i=0; i<(1<<n); i++)
	{
		int X = 0, Y = 0;
		for(int j=0; j<n; j++)
		{
			if((i&(1<<j)))
			{
				Y+=c[j];
				X+=v[j];
			}
		}
		maxPos = max(maxPos, X-Y);
	}
	cout<<maxPos<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main() {
	int a,b,m; cin>> a >> b>>m;
	vector<int> va(a),vb(b);
	int min_a = 1000000;
	int min_b = 1000000;
	for(int i=0; i<a;++i){
		 cin >>va[i];
		 min_a = min(min_a, va[i]);
	}
	for(int i=0; i<b;++i) 
	{
		cin >>vb[i];
		min_b = min(min_b, vb[i]);
	}
	int out = min_a + min_b;
	for(int j=0;j<m;++j){
		int x,y,c;cin >> x >> y>>c;
		out = min(out, va[x-1]+vb[y-1]-c);
	}
	cout << out << endl;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n,0);
    int id;
    for (int i = 2; i < n + 1; i++)
    {
        cin >> id;
        id--;
        v[id]++;
    }
    for (int i = 0; i < n; i++)
    {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4052
s = input().rstrip()
tmp = 0
pw = 1
from collections import Counter
c = Counter()
c[0] += 1

for d in s[::-1]:
    tmp += int(d) * pw
    tmp %= 2019
    pw *= 10
    pw %= 2019
    c[tmp] += 1

print(sum([v*(v-1)//2 for v in c.values() if v > 1]))

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);

    vector< vector<int> > e(N+1);
    vector<int> d(N+1,0);

    int a,b;
    Rep(i,N-1){
        Scd2(a,b);
        a--;b--;
        d[a]++;
        d[b]++;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    vector<int> c(N);

    Rep(i,N){
        Scd(c[i]);
    }

    sort( c.begin(), c.end() );
    reverse( c.begin(), c.end() );

    // int dmax = 0;
    // Rep(i,N){
    //     if( dmax < d[i] ){
    //         dmax = d[i];
    //     }
    // }
    //

    deque<int> q;

    vector<int> ansc(N,0);
    // vector<int> se(N,false);

    q.push_back(0);

    int ii = 0;
    int ans = 0;

    while( !q.empty() ){
        int from = q.front();
        q.pop_front();
        ans += c[ii];
        ansc[from] = c[ii++];
        for( int to : e[from] ){
            if( !ansc[to] ){
                q.push_front( to );
            }
        }
    }

    printf ("%d\n", ans - c[0] );

    Rep(i,N){
        printf ("%d%c", ansc[i], i == N-1 ? '\n' : ' ' );
    }


    return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        vi a(n),b(n),c(n);
        rep(i,n)cin>>a[i];
        rep(i,n)cin>>b[i];
        rep(i,n-1)cin>>c[i];
        int ans=0;
        rep(i,n)
        {
                ans+=b[a[i]-1];
                if(i==0)continue;
                if(a[i]-a[i-1]==1)ans+=c[a[i-1]-1];
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int dp[3030][3030];

signed main(){
  int n,t;
  cin >> n >> t;
  vector<P> A(n);
  rep(i,0,n) cin >> A[i].first >> A[i].second;
  sort(A.begin(),A.end());
  rep(i,1,n+1){
    rep(j,0,t+1){
      if(j >= A[i-1].first) dp[i][j] = max(dp[i-1][j],dp[i-1][j - A[i-1].first] + A[i-1].second);
      else dp[i][j] = dp[i-1][j];
    }
  }
  int ans = 0;
  // rep(i,0,n+1){
    // rep(j,0,t){
      // cout << dp[i][j] << ' ';
    // }
    // cout << endl;
  // }
  rep(i,1,n+1){
    ans = max(ans,dp[i-1][t-1] + A[i-1].second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 71936