akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int A = atoi(S.substr(0, 2).c_str());
    int B = atoi(S.substr(2, 2).c_str());
    bool flgA = 1 <= A && A <= 12;
    bool flgB = 1 <= B && B <= 12;
    //    cout << A << B;
    if (flgA && flgB)
    {
        cout << "AMBIGUOUS"
             << "\n";
    }
    else if (flgA && !flgB)
    {
        cout << "MMYY"
             << "\n";
    }
    else if (!flgA && flgB)
    {
        cout << "YYMM"
             << "\n";
    }
    else
    {
        cout << "NA"
             << "\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    ll N, K;
    cin >> N >> K;

    vector<ll> A;
    A.resize(N);
    rep(i,N){
        int tmp;
        cin >> tmp;
        tmp--;
        A[i]=tmp;
    }

    map<ll,ll> Map;
    queue<ll> que;
    vector<ll> vec;
    vec.resize(N,0);

    que.push(0);
    ll pos;
    ll cnt = 0;
    while(!que.empty()){
        ll now = que.front();  que.pop();
        ll nx = A[now];
        //cnt++;
       // cout << "cnt: " << cnt << endl;

        if(cnt==K){
            cout << now+1 << endl;
            return 0;
        }

        if(Map[now]==0){
            Map[now]++;
            vec[now]=cnt;
            cnt++;
            //cout << "now: " << now << endl;
            que.push(nx);
        }else{
            pos = now;
            break;
        }
    }

    ll rest = K - cnt;
    ll L = cnt - vec[pos];
    ll final = rest % L;

    // cout << "pos: " << pos << endl;
    // cout << "rest: " << rest << endl;
    // cout << "L: " << L << endl;
    // cout << "final: " << final << endl;

    queue<ll> que2;
    que2.push(pos);
    ll ans;
    rep(i,final+1){
        ll now = que2.front(); que2.pop();
        //cout << "now2: " << now << endl;
        ll nx = A[now];
        que2.push(nx);
        ans = now;
    }

    cout << ans+1 << endl;
}

Measured memory_bytes: 16388
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int k;
int h[N];
int mem[N];

int go(int idx){
    if(idx >= n)
        return 0;
    if(mem[idx] != -1)
        return mem[idx];
    int best = 1e9;
    for(int i = 1; i <= k; i++){
        if(idx + i <= n){
            best = min(best , go(idx + i) + abs(h[idx] - h[idx + i]));
        }
    }
    return mem[idx] = best;
}

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &h[i]);
    }
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , go(1));
}


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

struct UnionFind {
  unordered_map<int, int> parent, siz;
  UnionFind(int n) {
    for (int i = 0; i < n; i++) {
      parent[i]=i;
      siz[i]=1;
    }
  }
  int find (int x){
    if (parent[x]==x) return x;
    return find(parent[x]);
  }
  void unite(int x, int y){
    int routeX = find(x);
    int routeY = find(y);
    if (routeX == routeY) return;
    
    if (siz[routeX] < siz[routeY]) swap(routeX,routeY);
    parent[routeY] = routeX;
    siz[routeX] += siz[routeY];
  }
  int size(int x) {return siz[find(x)];}
  bool same(int x, int y) {return find(x)==find(y);}
};


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

  UnionFind uf = UnionFind(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    uf.unite(--A,--B);
  }

  int maxSize=0;
  for (int i = 0; i < N; i++) {
    maxSize = max(maxSize, uf.size(i));
  }

  cout << maxSize << endl;
  return 0;
}

Measured memory_bytes: 19784
program green_bin
    implicit none
    integer(4):: n,i,j,k
    integer(4):: a(10)
    integer(8) :: count=0
    character(10):: c
    character(10),allocatable:: ca(:)
    
    read*, n
    allocate(ca(n))

    do i=1,n
        read*,c(:)
        do j=1,10
            a(j) = ichar(c(j:j))
        end do
        call merge_sort(a(:),1,10)
        do j=1,10
            ca(i)(j:j) = char(a(j))
        end do
        
    end do

    call smerge_sort(ca(:), 1, n)

    block; integer(4):: fst, scd
        fst=1; scd=2
        do while (scd <= n)
            if (ca(fst)==ca(scd)) then
                count = count + scd-fst
                scd=scd+1
            else
                fst=scd
                scd=scd+1
            end if
        end do
    end block

    print*, count



contains
recursive subroutine merge_sort(ar,fst,lst)
    integer(4):: ar(:), fst, lst, mid, tmp

    if (lst-fst < 2)then
        if (ar(lst) < ar(fst)) then
            tmp = ar(fst)
            ar(fst) = ar(lst)
            ar(lst) = tmp
        end if
        return
    end if

    mid = (fst+lst)/2
    call merge_sort(ar,fst,mid)
    call merge_sort(ar,mid+1,lst)
    call merge(ar,fst,mid,lst)
end subroutine

subroutine merge(ar, fst, mid, lst)
    integer(4):: ar(:), fst, mid, lst
    integer(4),pointer:: tmp(:)
    integer(4):: it, il, ir
    
    allocate(tmp(lst-fst+1))
    it=1
    il=fst
    ir=mid+1

    do while(il <= mid .and. ir <= lst)
        if (ar(il) <= ar(ir)) then
            tmp(it)=ar(il)
            il=il+1
        else
            tmp(it)=ar(ir)        
            ir=ir+1
        end if
        it=it+1
    end do

    if(ir > lst) then
        tmp(it:) = ar(il:mid)
    else
        tmp(it:) = ar(ir:lst)
    end if

    ar(fst:lst) = tmp(:)
    deallocate(tmp)
    
end subroutine

recursive subroutine smerge_sort(ar, fst, lst)
    character(10):: ar(:), tmp
    integer(4):: fst, lst, mid

    if (lst-fst < 2) then
        if (ar(lst) < ar(fst)) then
            tmp = ar(fst)
            ar(fst) = ar(lst)
            ar(lst) = tmp
        end if
        return
    end if

    mid = (fst+lst)/2
    call smerge_sort(ar, fst, mid)
    call smerge_sort(ar, mid+1, lst)
    call smerge(ar, fst, mid, lst)
end subroutine

subroutine smerge(ar, fst, mid, lst)
    character(10):: ar(:)
    character(10),pointer:: tmp(:)
    integer(4):: fst, mid, lst
    integer(4):: it, il, ir

    allocate(tmp(lst-fst+1))
    it=1
    il=fst
    ir=mid+1

    do while(il <= mid .and. ir<=lst)
        if (ar(il) <= ar(ir)) then
            tmp(it) = ar(il)
            il=il+1        
        else
            tmp(it) = ar(ir)
            ir=ir+1
        end if
        it=it+1
    end do

    if (ir > lst) then
        tmp(it:) = ar(il:mid)
    else
        tmp(it:) = ar(ir:lst)
    end if
    ar(fst:lst) = tmp(:)
    deallocate(tmp)
end subroutine


    
end program green_bin

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

int main() {
  int A, B;
  char op;
  
  cin >> A >> op >> B;
  
  int answer;
  if (op == '+') {
    answer = A + B;
  }
  else {
    answer = A - B;
  }
  
  cout << answer << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,q;
    cin>>n>>m>>q;
    int l[m],r[m],a[q],b[q];
    int x[n][n]={};
    for(int i=0;i<m;i++){
        cin>>l[i]>>r[i];
        x[0][r[i]-1]++;
        if(l[i]<n)x[l[i]][r[i]-1]--;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++)x[i][j+1]+=x[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++)x[j+1][i]+=x[j][i];
    }
    for(int i=0;i<q;i++)cin>>a[i]>>b[i];
    for(int i=0;i<q;i++)cout<<x[a[i]-1][b[i]-1]<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,K;
vector<ll> T[3030][3030];
ll dp[3030][3030][4];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>K;
	FOR(i,K) {
		cin>>y>>x>>r;
		T[y-1][x-1].push_back(r);
	}
	FOR(y,H) FOR(x,W) {
		sort(ALL(T[y][x]));
		reverse(ALL(T[y][x]));
		FOR(i,(int)T[y][x].size()-1) T[y][x][i+1]+=T[y][x][i];
		for(i=2;i>=0;i--) {
			for(j=1;i+j<=3&&T[y][x].size()>=j;j++) dp[y][x][i+j]=max(dp[y][x][i+j],dp[y][x][i]+T[y][x][j-1]);
		}
		
		FOR(i,4) {
			dp[y+1][x][0]=max(dp[y+1][x][0],dp[y][x][i]);
			dp[y][x+1][i]=max(dp[y][x+1][i],dp[y][x][i]);
		}
	}
	
	
	cout<<dp[H][W-1][0]<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 508916
import java.util.Scanner;

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

        int n = sc.nextInt();
        int l = sc.nextInt();

        String[] chars = new String[n];
        for (int i = 0; i < n; i++) {
            chars[i] = sc.next();
        }

        for(int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - i - 1; j++) {
                int k = 0;
                char jchar, jpchar;
                boolean isTarget = false;
                boolean isCompleted = false;

                while(!isCompleted && k < l) {
                    jchar = chars[j].charAt(k);
                    jpchar = chars[j + 1].charAt(k);

                    if(jchar > jpchar) {
                        isCompleted = true;
                        isTarget = true;
                    } else if(jchar < jpchar) {
                        isCompleted = true;
                    }
                    k++;
                }

                if(isTarget) {
                    String tmp = chars[j];
                    chars[j] = chars[j + 1];
                    chars[j + 1] = tmp;
                }
            }
        }

        for (int i = 0; i < n; i++) {
            System.out.print(chars[i]);
        }
    }
}


Measured memory_bytes: 9876
import java.io.*;
import java.util.*;

public class Main {
	
	static long mod= (long) 1e9+7;
	
		
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt();
		int[] arr=new int[n];
		long ans=0;
		int max=0;
		for(int i=0;i<n;i++) {
			int a=Reader.nextInt();
			if(max>a) {
				ans+=(max-a);
			}
			max=Math.max(a,max);
		}
		out.println(ans);
		
		out.flush();
		
	}

}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init() throws IOException {
        reader = new BufferedReader(
                new FileReader("C:\\Users\\samee\\Desktop\\GRE prep\\confusion.txt"));
        tokenizer = new StringTokenizer("");
    }
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
        return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}

Measured memory_bytes: 54600
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
string T;
void input() {
  cin >> S >> T;
  cout << (T + S) << endl;
  ;
  ;
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 2e6 + 5;

ll n, m;
ll a[N];

int fix[N];


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n;
    m = 1;
    for (int i = 0; i < n; i++)
        m = m + m;
    for (ll i = 1; i <= m; i++)
        cin >> a[i];
    sort (a + 1, a + m + 1);
    reverse (a + 1, a + m + 1);
    if (a[1] == a[2]){
        cout << "No" << endl;
        return 0;
    }
    fix[1] = 1;
    for (int i = 0; i < n; i++){
        deque < int > Q;
        for (int j = 1; j <= m; j++){
            if (fix[j]){
                Q.push_back (a[j]);
                continue;
            }
            if (Q.size() == 0)
                continue;
            if (Q.front() > a[j]){
                Q.pop_front();
                fix[j] = 1;
            }
        }
        if (Q.size() > 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 5984
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

pair<ll, ll> get_inter(ll s1, ll e1, ll s2, ll e2){
    if(s1 > s2) return get_inter(s2, e2, s1, e1);
    else if(e1 <= s2) return P(0,0);
    else return P(s2, min(e1, e2));
}

int main(){
    ll N, M; cin >> N >> M;
    map<ll, ll> m;
    REP(i, M){
        ll a, b; cin >> a >> b; m[a] = (m[a] <= 0) ? b : min(m[a], b);
    }
    map<ll, ll> m_is;
    FORMAP(it, m){
        if(it == m.begin()){
            m_is[m.begin()->first] = m.begin()->second;
            continue;
        }
        auto it_t = m_is.upper_bound(it->first);
        auto it_p = it_t;
        if(m_is.size() == 1){
            it_p = m_is.begin(); it_t = m_is.begin();
        }
        else{
            if(it_t == m_is.begin())
                it_p++;
            else if(it_t == m_is.end()){
                it_t = m_is.end()--; it_p = it_t--;
            }
          	else{
              it_p = it_t--;
            }
        }
        
        auto inter_t = get_inter(it->first, it->second, it_t->first, it_t->second);
        auto inter_p = get_inter(it->first, it->second, it_p->first, it_p->second);
        if(inter_t != PL(0ll,0ll)){
            m_is.erase(it_t); m_is[inter_t.first] = inter_t.second;
        }
        else if(inter_p != PL(0ll, 0ll)){
            m_is.erase(it_t); m_is[inter_p.first] = inter_p.second;
        }
        else{
            m_is[it->first] = it->second;
        }
    }
    cout << m_is.size() << endstr;
    return 0;
}


Measured memory_bytes: 6528
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (chk(x)==chk(y)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	private static int chk(int i) {
		Set<Integer> seta = new HashSet<>();
		Set<Integer> setb = new HashSet<>();
		seta.add(1);
		seta.add(3);
		seta.add(5);
		seta.add(7);
		seta.add(8);
		seta.add(10);
		seta.add(12);
		setb.add(4);
		setb.add(6);
		setb.add(9);
		setb.add(11);
		if (seta.contains(i)) {
			return 0;
		} else if (setb.contains(i)) {
			return 1;
		}
		return 2;
	}
}


Measured memory_bytes: 21716
#include<stdio.h>
#include<math.h>

int main(){
	int n;			//数字の個数
	long int inum;	//与えられる整数
	int flg = 0;	//フラグ
	int count = 0;	//素数の数
	
	//個数の入力
	scanf("%d",&n);
	
	for(int i = 0;i < n;i++){
		//整数の入力
		scanf("%ld",&inum);
		
		//2は素数
		if(inum == 2){
			flg = 1;
		}
		else{
			//偶数でなければ進む
			if((inum % 2) != 0){
				int j = 3;
				
				//3からinumの平方根までで割り切れるか
				while(j <= sqrt(inum)){
					//割り切れたとき
					if((inum % j) == 0){
						flg = 2;
						break;
					}
					//jを2ずつ足す
					j += 2;
				}
				//割り切れていなかったら素数
				if(flg != 2){
					flg = 1;
				}
			}
		}
		
		//フラグが1ならカウント
		if(flg == 1){
			count++;
		}
		//フラグを0に戻す
		flg = 0;
	}
	
	//出力
	printf("%d\n",count);
	
	return 0;
}



Measured memory_bytes: 2052
#include <stdio.h>
int main(void){
    int a, b, c, count=0;
    scanf("%d %d %d", &a, &b, &c);
    
    for(; a<=b; a++){
        if(c%a == 0) count++;
    }
    printf("%d\n", count);
    
    return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	int M;
	cin >> M;
	vector<int>A(M);
	rep(i, M) {
		cin >> A[i];
	}
	vector<vector<int>>B(M, vector<int>(N));
	rep(i, M) {
		rep(j, N) {
			cin >> B[i][j];
		}
	}
	vector<int>cnt(N,0);
	rep(i, M) {
		rep(j, N) {
			if (B[i][j] == A[i]) {
				cnt[j]++;
			}
			else {
				cnt[A[i] - 1]++;
			}
		}
	}
	rep(i, N) {
		cout << cnt[i] << endl;
	}
}


Measured memory_bytes: 3120
N = input()
T = map(int, raw_input().split())
M = input()
P = []
X = []
for _ in range(M):
    p, x = map(int, raw_input().split())
    P.append(p)
    X.append(x)
res_normal = sum(T)
for i in range(M):
    print res_normal - T[P[i] - 1] + X[i]


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

vector<int> G[100100];
int p[100100], d[100100];
priority_queue<pair<int, int>> pq;
bool visited[100100];

void dfs(int v=0, int par=-1) {
  p[v] = par;
  if (v) d[v] = d[par] + 1;
  for (int u: G[v]) {
    if (u == par) continue;
    dfs(u, v);
  }
  if (v && G[v].size() == 1) pq.push({d[v], v});
}

void check() {
  while (pq.size()) {
    int v = pq.top().second;
    pq.pop();
    if (visited[v]) continue;
    visited[v] = 1;
    v = p[v];
    if (v == -1 || visited[v]) {
      cout << "First\n";
      exit(0);
    }
    visited[v] = 1;
    v = p[v];
    if (v != -1 && !visited[v]) pq.push({d[v], v});
  }
  cout << "Second\n";
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if (n & 1) {
    cout << "First\n";
    return 0;
  }
  dfs();
  check();

  




  
  return 0;
}

Measured memory_bytes: 10228
use itertools::iproduct;
use proconio::input;

fn main() {
    input!(r: usize, c: usize, goods: [(usize, usize, u64)]);

    let mut val = array![0; r + 1, c + 1];
    for &(r, c, v) in &goods {
        val[r][c] = v;
    }

    let mut dp = array![0; r + 1, c + 1, 4];
    for (i, j, k) in iproduct!(1..=r, 1..=c, (0..=3).rev()) {
        max_assign!(dp[i][j][0], dp[i - 1][j][k]);
        max_assign!(dp[i][j][k], dp[i][j - 1][k]);
        if val[i][j] != 0 {
            max_assign!(dp[i][j][1], dp[i - 1][j][k] + val[i][j]);
            if k > 0 {
                max_assign!(dp[i][j][k], dp[i][j - 1][k - 1] + val[i][j]);
            }
        }
    }

    println!("{}", dp[r][c].iter().max().unwrap())
}

#[macro_export]
macro_rules! array {
    ($v:expr; $l:expr, $($r:expr),*) => { vec![array!($v; $($r),*); $l] };
    ($v:expr; $l:expr) => { vec![$v; $l] };
    () => { vec![] };
}

#[macro_export]
macro_rules! max_assign {
    ($x:expr, $y:expr) => {{
        let rhs = $y;
        if $x < rhs {
            $x = rhs;
            true
        } else {
            false
        }
    }};
}


Measured memory_bytes: 713560
#include <bits/stdc++.h>
#define maxn 200005
#define oo 1e9+5
#define foru(a,b,c) for (int a=b;a<=c;a++)
#define ford(a,b,c) for (int a=b;a>=c;a--)
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define ll long long
#define forv(a,b) for(auto&a:b)
#define base 1000000007
using namespace std;
struct data
{
    int x,t;
};
bool cmp(data p1,data p2)
{
    return p1.x<p2.x;
}
int n;
data a[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("connect.inp", "r", stdin);
    //freopen("connect.out", "w", stdout);
    cin >> n;
    foru(i,1,n)
    {
        cin >> a[i].x;
        a[i].t=1;
    }
    foru(i,n+1,2*n)
    {
        cin >> a[i].x;
        a[i].t=2;
    }
    sort(a+1,a+2*n+1,cmp);
    multiset<int> h1,h2;
    ll kq=1;
    foru(i,1,2*n)
    {
        if (a[i].t==1)
        {
            if (h2.size()==0) h1.insert(a[i].x);
            else
            {
                kq=(kq*h2.size())%base;
                h2.erase(h2.begin());
            }
        }
        else
        {
            if (h1.size()==0) h2.insert(a[i].x);
            else
            {
                kq=(kq*h1.size())%base;
                h1.erase(h1.begin());
            }
        }
    }
    cout << kq;
}


Measured memory_bytes: 6528
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		String ans = "Yes";

		int prev = 0;
		int max = 0;
		for(int i = 0; i < num; i++){
			int height = sc.nextInt();
			if(prev-1 > height){
				ans = "No";
				break;
			}else if(prev > height){
				if(height < max-1){
					ans = "No";
					break;
				}
			}
			max = Math.max(height, max);
			prev = height;
		}
		
		System.out.println(ans);
	}
}




Measured memory_bytes: 46068
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll N, K;

signed main(){
    cin >> N >> K;
    ll ans = 0;
    for(ll k=K; k<=N+1; k++){
        ll m = (k-1)*k/2;
        ll M = N*(N+1)/2 - (N-k)*(N-k+1)/2;
        ans += M-m+1;
        ans %= MOD;
        //cout << m << " " << M << endl;
    }
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);

	for (auto& e : a) {
		cin >> e;
	}

	for (int i = 0; i < n; i++) {
		if (a.at(i) % 2 == 0) {
			if (a.at(i) % 3 != 0 && a.at(i) % 5 != 0) {
				cout << "DENIED" << endl;
				break;
			}
		}
		if (i == n - 1) {
			cout << "APPROVED" << endl;
		}
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <vector>

int n, m;
const int nmax = 50005;
const int mmax = 25;
const int INF = 100000;

int coins[mmax];
int dp[nmax];

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

    for (size_t i = 0; i < m; ++i)
    {
        std::cin >> coins[i];
    }

    dp[0] = 0;
    for (size_t j = 1; j <= n; ++j)
    {
        dp[j] = INF;
    }

    for (size_t i = 0; i < m; ++i)
    {
        for (size_t j = 1; j <= n; ++j)
        {
            if (coins[i] <= j)
                dp[j] = std::min(dp[j], dp[j - coins[i]] + 1);
        }
    }

    std::cout << dp[n] << std::endl;
}



Measured memory_bytes: 3296
#include<stdio.h>
int min(int,int);
#define N 100
int main(){
  int n,p[N],m[N][N];
  int i,l,j,k;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
m[i][j]=200000;
      for(k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}

int min(int a,int b){
if(a<b){
return a;
}else{return b;}
}

Measured memory_bytes: 632
N = int(input())
K = int(input())
x = input().split()

sum = 0
for i in range(0,len(x)):
    if abs(K-int(x[i]))<int(x[i]):
        sum += abs(K-int(x[i]))*2
    else:
        sum += int(x[i])*2

print(sum)

Measured memory_bytes: 9152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String s = sc.next();
        
        if(c<b){
            if((s.substring(a, c-1).contains("##")) || s.substring(b, d-1).contains("##")){
                System.out.println("No");
                return;
            }
        }else if(c<d){
            if(s.substring(a, d-1).contains("##")){
                System.out.println("No");
                return;
            }
        }else{
            if(s.substring(a, c-1).contains("##")){
                System.out.println("No");
                return;
            }else if(!s.substring(b-2, d+1).contains("...")){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 26600
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S = keyboard.next();	
		String T = keyboard.next();	
			
		String[] strArrayS = S.split("");
		String[] strArrayT = T.split("");
		
		int Slong = S.length();
		
		int count = 0;
		for (int i=0; i<Slong; i++) {
			if(strArrayS[i].contentEquals(strArrayT[i])) {
				
			}else {
				count++;
			}
		}
					
							
		System.out.println(count);
		keyboard.close();	
	}
}

Measured memory_bytes: 67748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int Q, H, S, D;
	cin >> Q >> H >> S >> D;

	ll a = S;
	a = min(H * 2ll, a);
	a = min(Q * 4ll, a);

	ll b = D;
	b = min(S * 2ll, b);
	b = min(H * 4ll, b);
	b = min(Q * 8ll, b);

	int N;
	cin >> N;
	ll kotae = N / 2 * b + N % 2 * a;
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int k = 0;
    int x = 0;
    int n = 0;
    int h = 0;
    int w = 0;
    cin >> n >> h >> w;

    //tateに関して
    do{
        k++;
    }while(k + h <= n);

    //yokoに関して
    do{
        x++;
    }while (x + w <= n);

    cout << k * x;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MOD = 998244353;

const int MAX_len = 300;

const int MAX_SZ = 3000;

int64 f[MAX_SZ+1][MAX_SZ+1];



int solve(int A,int B,int C,int D){
	f[A][B] = 1;
	for (int64 i = A; i <= C; ++i)
		for (int64 j = B; j <= D; ++j){
			if(i-1 >= 0 && j-1 >= 0){
				f[i][j] -= (i-1)*(j-1)%MOD*f[i-1][j-1]%MOD;
				while(f[i][j] < 0)	f[i][j] += MOD;
			}
			if(i + 1 <= C){
				f[i+1][j] += (int64)j*f[i][j]%MOD;
				while(f[i+1][j] >= MOD)	f[i+1][j] -= MOD;
			}
			if(j + 1 <= D){
				f[i][j+1] += (int64)i*f[i][j]%MOD;
				while(f[i][j+1] >= MOD)	f[i][j+1] -= MOD;
			}
		}

	return f[C][D];
}


int main(){
	int A,B,C,D;	cin >> A >> B >> C >>D;
	int ans = solve(A,B,C,D);
    printf("%d\n",ans);
}





Measured memory_bytes: 73796
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> ans;
    if(n % 2 == 0){
        REP(i, n){
            for(ll j = i + 1; j < n; j++){
                if(n - 1 - i == j) continue;
                ans.push_back({i + 1, j + 1});
            }
        }
    }
    else{
        REP(i, n - 1){
            for(ll j = i + 1; j < n - 1; j++){
                if(n - 2 - i == j) continue;
                ans.push_back({i + 1, j + 1});
            }
        }
        REP(i, n - 1){
            ans.push_back({i + 1, n});
        }
    }
    cout << ans.size() << endl;
    REP(i, ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}


Measured memory_bytes: 512
def solve():
  ans = 1
  N = int(input())
  A = list(map(int, input().split()))
  ud = 0
  for i in range(N-1):
    a = A[i+1]-A[i]
    if a*ud<0:
      ans += 1
      ud = 0
    elif ud==0:
      ud = a
  return ans
print(solve())

Measured memory_bytes: 19908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b,c; cin >> a >> b >> c;
	std::vector<int> v={abs(a-b),abs(b-c),abs(c-a)};
	sort(v.rbegin(), v.rend());
	cout << v[1] + v[2] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>

#define R_MAX 10
#define C_MAX 10000

using namespace std;

int R,C;
int org_m[R_MAX][C_MAX], m[R_MAX][C_MAX];

void FlipRow(int i){
	for(int j = 0; j < C; ++j)
		m[i][j] = 1 ^ m[i][j];
}

void FlipColumn(int j){
	int cnt = 0;
	for(int i = 0; i < R; ++i){
		cnt += m[i][j];
	}
	if( cnt > R/2 ){
		for(int i = 0; i < R; ++i){
			m[i][j] = 1 ^ m[i][j];
		}
	}
}

int CountOsenbei(){
	int ret = 0;
	for(int i = 0; i < R; ++i){
		for(int j = 0; j < C; ++j){
			ret += 1 ^ m[i][j];
		}
	}
	return ret;
}

int main()
{
	while(true){
		int ans = 0;

		scanf("%d%d", &R, &C);
		if( R == 0 && C == 0 )
			break;

		for(int i = 0; i < R; ++i){
			for(int j = 0; j < C; ++j){
				scanf("%d", &m[i][j]);
				org_m[i][j] = m[i][j];
			}
		}

		for(int i = 0; i < (int)pow(2.0,R); ++i){
			
			for(int j = 0; j < R; ++j){
				int b = (int)pow(2.0,j);
				if( i & b ){
					FlipRow( j );
				}
			}

			for(int j = 0; j < C; ++j){
				FlipColumn( j );
			}

			ans = max( ans, CountOsenbei() );

			for(int j = 0; j < R; ++j){
				for(int k = 0; k < C; ++k){
					m[j][k] = org_m[j][k];
				}
			}
		}

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

Measured memory_bytes: 1668
#include<cstdio>
#include<string>
#include<iostream>
#include<cmath>

using namespace std;

int main(){
    int a, b;
    cin >> a;
    cin >> b;
    int keta = 0;
    int d = b;
    while (d > 0){
        d /= 10;
        keta++;
    }

    int c = a * pow(10, keta) + b;
    // cout << c << "\n";
    for(int i = 1; i < sqrt(c) + 1; i++){
        if (c % i == 0 && c / i == i){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    
}

Measured memory_bytes: 512
# 再帰を用いて実装
module Color
   WHITE = 0
   GRAY = 1
   BLACK = 2
end
def dfs(u)
  # puts "unit : #{u}, color : #{$color[u]}"
  $color[u] = Color::GRAY
  $d[u] = $time
  $time += 1
  for v in 0...($m.size) do
    if !$m[u][v].zero? && $color[v] == Color::WHITE
      # puts "HIT! unit : #{v}, color : #{$color[v]}"
      dfs(v)
    end
  end
  $color[u] = Color::BLACK
  $f[u] = $time
  $time += 1
end

n = gets.to_i
$m = Array.new(n) { Array.new(n, 0) }
n.times do
  u, k, *v_arr = gets.split.map(&:to_i)
  for v in v_arr
    $m[u-1][v-1] = 1
  end
end
# for u in $m
#   puts u.join(' ')
# end
$time = 1
$color = Array.new(n, Color::WHITE)
$d = Array.new(n)
$f = Array.new(n)
n.times do |u|
  if $color[u] == Color::WHITE
    dfs(u)
  end
end
for i in 0...n do
  print i+1
  print ' '
  print $d[i]
  print ' '
  puts $f[i]
end


Measured memory_bytes: 7096
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

def counter(x):
  cnt=0
  for i in a:
    cnt+=(i-1)//x
    
  if cnt<=k:
    return True
  
  else:
    return False

high=a[-1]
low=0
while (high-low)>1:
  mid =(high+low)//2
  if counter(mid):
    high=mid

  else:
    low=mid

print(high)

Measured memory_bytes: 30684
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var [n,m]=arr.shift().split(" ").map(Number);
   if(n==0 && m==0)break;
   var [a,b,c]=arr.slice(0,3).map(v=>v.split(" ").slice(1).map(Number).reverse());
   var obj={};
   var result =-1;
   var bfs=[[a,b,c,0]];
   while(true){
      if(bfs.length==0)break;
      var [a,b,c,cnt]=bfs.shift();    
      if(cnt>m)break;
      if((a.length==0 && b.length==0) || (b.length==0 && c.length==0)){
         result=cnt;
         break;
       }
      var str="a"+a.join(",")+"b"+b.join(",")+"c"+c.join(",");
      if(obj.hasOwnProperty(str))continue;
      else obj[str]=1;    
      if(a.length==0)bfs.push([[b[0]],b.slice(1),c,cnt+1]);
      else if(b.length==0)bfs.push([a.slice(1),[a[0]],c,cnt+1]);
      else if(a[0]<b[0])bfs.push([[b[0]].concat(a),b.slice(1),c,cnt+1]);
      else if(a[0]>b[0])bfs.push([a.slice(1),[a[0]].concat(b),c,cnt+1]);
         
      if(b.length==0)bfs.push([a,[c[0]],c.slice(1),cnt+1]);
      else if(c.length==0)bfs.push([a,b.slice(1),[b[0]],cnt+1]);
      else if(b[0]<c[0])bfs.push([a,[c[0]].concat(b),c.slice(1),cnt+1]);
      else if(b[0]>c[0])bfs.push([a,b.slice(1),[b[0]].concat(c),cnt+1]);
   }
   console.log(result);
   arr=arr.slice(3);
}


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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

const int NMax = 1e5 + 50;

int main() {
	Boost();

	int n, w;
	cin >> n >> w;

	vector < int > DP(NMax, w + 5);
	DP[0] = 0;
	for (int i = 0; i < n; ++i) {
		int x, y; cin >> x >> y;
		for (int j = NMax - 1; j >= y; --j) {
			if ((DP[j - y] + x) < DP[j]) {
				DP[j] = DP[j - y] + x;
			}
		}
	}

	for (int i = NMax - 1; i >= 0; --i) {
		if (DP[i] <= w) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 640
S = []
gets.chomp.chars.slice_when{|a,b| a != b}.each do |v|
  S << [v[0], v.size]
end

def acc(n)
  n*(n+1)/2
end

count = 0

if S[0][0] == ">"
  s = S.shift
  count += acc(s[1])
end

S.each_slice(2) do |a,b|
  if b.nil?
    count += acc(a[1])
    break
  end

  if a[1] < b[1]
    count += acc(a[1]-1)
    count += acc(b[1])
  else
    count += acc(a[1])
    count += acc(b[1]-1)
  end
end

puts count



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

int main(){
	ll N,K;
	cin >> N >>K;
	vector<ll> H(N);
	rep(i,N){
		cin >> H[i];
	}
	
	sort(H.begin(),H.end());
	reverse(H.begin(),H.end());
	
	rep(i,min(K,N)){
		H[i] = 0;
	}
	
	ll ans = 0;
	
	rep(i,N){
		ans += H[i];
	}
	
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




int h, w;
int ans;
string s[25];

int main() {

	cin >> h >> w;

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

	rep(i, h) {
		rep(j, w) {
			if (s[i][j] != '#') {
				queue<PII>point;
				bool f[25][25];
				rep(i, h) rep(j, w) f[i][j] = true;
				int cnt[25][25];
				cnt[i][j] = 0;
				point.push(dmp(i, j));
				f[i][j] = false;
				while (!point.empty()) {
					int x = point.front().se, y = point.front().fi; point.pop();
					rep(k, 4) {
						if (x + dx[k] >= 0 && y + dy[k] >= 0 && x + dx[k] < w && y + dy[k] < h && s[y + dy[k]][x + dx[k]] != '#' && f[y + dy[k]][x + dx[k]]) {
							cnt[y + dy[k]][x + dx[k]] = cnt[y][x] + 1;
							point.push(dmp(y + dy[k], x + dx[k]));
							f[y + dy[k]][x + dx[k]] = false;
						}
					}
					ans = max(ans, cnt[y][x]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<62)

signed main(){
    int n,K;
    cin>>n>>K;

    vector<pii> vp;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        vp.pb(pii(a,b));
    }

    int ans = INF;

    rep(i,n){
        for(int j=i;j<n;j++){
            for(int k=j;k<n;k++){
                for(int l=k;l<n;l++){
                    int minx = INF, maxx = -INF;
                    int miny = INF, maxy = -INF;

                    minx = min(min(vp[i].first,vp[j].first),min(vp[k].first, vp[l].first));
                    maxx = max(max(vp[i].first,vp[j].first),max(vp[k].first, vp[l].first));

                    miny = min(min(vp[i].second,vp[j].second),min(vp[k].second, vp[l].second));
                    maxy = max(max(vp[i].second,vp[j].second),max(vp[k].second, vp[l].second));

                    int c = 0;
                    rep(m,n){
                        int x = vp[m].first;
                        int y = vp[m].second;
                        if( minx<=x && x<=maxx && miny<=y && y<=maxy ){
                            c++;
                        }
                    }
                    if(c>=K)ans = min(ans,(maxx-minx)*(maxy-miny));

                }
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cout << setprecision(10);
  long N, s=0;
  cin >> N;
  for(int i=1; i<=N; i++){
    if (i%3>0 && i%5>0) s+=i;
  }
  cout << s << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int n;
const int N = 2e5 + 5;
int a[N], b[N];
int calc (vector<int> a) {
    sort(all(a));
    int n = (int) a.size();
    if (n % 2)
        return a[n / 2];
    else 
        return a[n / 2] + a[n / 2 - 1];
}
vector<int> c, d;
void solve() {  
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i] >> b[i];
        c.push_back(a[i]);
        d.push_back(b[i]);
    }
    auto mn = calc(c);
    auto mx = calc(d);
    cout << (mx - mn + 1);
}       
    

Measured memory_bytes: 11432
/*
Problem : https://atcoder.jp/contests/agc033/tasks/agc033_a
Algorithm : bfs
Status : 
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 1005;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};

int n,m,cnt;
int a[MAXN][MAXN];

struct Node{
	int x,y,time;
};

queue<Node> q;

bool check(int x,int y){
	return x >= 1 && x <= n && y >= 1 && y <= m;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			char c;
			cin >> c;
			a[i][j] = (c == '#');
			if(a[i][j]){
				cnt++;
				q.push((Node){i,j,0});
			}
		}
	}
	if(cnt == n * m){
		printf("0\n");
		return 0;
	}
	while(!q.empty()){
		Node p = q.front();
		q.pop();
		if(cnt >= n * m){
			printf("%d\n",p.time + 1);
			return 0;
		}
		for(int i = 0;i < 4;i++){
			int nx = p.x + dx[i];
			int ny = p.y + dy[i];
			if(check(nx,ny) && !a[nx][ny]){
				cnt++;
				a[nx][ny] = 1;
				q.push((Node){nx,ny,p.time + 1});
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16272
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
string A,B,C;
int main(int argc, char const *argv[])
{
    cin>>A>>B>>C;
    if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
while True:
    if a*b*1 % 2 != 0:
        print("Yes")
        break

    elif a*b*2 % 2 != 0:
        print("Yes")
        break

    elif a*b*3 % 2 != 0:
        print("Yes")
        break

    else:
        print("No")
        break


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,M;
  int X,Y;
  int x,y;
  vector<int> vx;
  vector<int> vy;
  cin>>N>>M>>X>>Y;
  vx.push_back(X);
  vy.push_back(Y);
  for(int i=0;i<N;++i){
    cin>>x;
    vx.push_back(x);
  }
  for(int i=0;i<M;++i){
    cin>>y;
    vy.push_back(y);
  }
  sort(vx.begin(),vx.end(),greater<int>());
  sort(vy.begin(),vy.end());
  if(vx[0]<vy[0]){
    cout<<"No War";
  }
  else{
    cout<<"War";
  }
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int func (int n) {
  int sum=0;
  while(n > 0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  if (n%(func(n)) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632