akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
from collections import *
from heapq import *

N, M = map(int, input().split())
d = defaultdict(list)

for _ in range(N):
    A, B = map(int, input().split())
    d[M-A].append(B)

pq = []
ans = 0

for i in range(M-1, -1, -1):
    for v in d[i]:
        heappush(pq, -v)
    
    if len(pq)>0:
        ans += -heappop(pq)

print(ans)

Measured memory_bytes: 72028
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

x, y = map(int, input().split())

def combinations_count(n, r):
    if n <= 1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = 0

ans += combinations_count(x, 2)
ans += combinations_count(y, 2)
print(ans)


Measured memory_bytes: 5764
def is_even_str(s) :
    s1 = s[0:int(len(s)/2)]
    s2 = s[int(len(s)/2):]
    return (s1 == s2) 


S = input()
while len(S) > 0 :
    S =S[:-2]
    if (is_even_str(S)) :
        print(len(S))
        break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,m;
	cin>>n>>m;

	lli ans = n*(n-1)/2 + m*(m-1)/2;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s;
  scanf("%c",&s);
  if(s=='A'){
    printf("T");
  }
  else if(s=='T'){
    printf("A");
  }
  else if(s=='C'){
    printf("G");
  }
  else{
    printf("C");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  long n,s,a,k,i,j,m=998244353;cin>>n>>s;
  vector<long>d(3001);
  for(i=0;i<n;i++){
    cin>>a;
    for(j=s;j>=a;j--)d[j]=(d[j]+d[j-a])%m;
    d[a]++;d[0]++;k+=d[s];
  }cout<<k%m;
}

Measured memory_bytes: 256
dic = dict()

n, k = list(map(int, input().split()))
balls = list(map(int, input().split()))

for ball in balls:
  if ball in dic:
    dic[ball] += 1
  else:
    dic[ball] = 1
    
nums = list(dic.values())
if len(nums) <= k:
  print(0)
else:
  print(sum(sorted(nums, reverse = True)[k:]))

Measured memory_bytes: 32184
#include <stdio.h>

int main(void){
     int a,b,d,r;
     double f;
      scanf("%d %d",&a,&b);
      d = a/b;
      r = a%b;
      f = (double)a/b;
       printf("%d %d %lf\n",d,r,f);
        return 0;
     } 

Measured memory_bytes: 636
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool ans = false;
  if (abs(a-c)<=d) ans = true;
  if (abs(a-b)<=d && abs(b-c)<=d) ans = true;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def aux(s)
  s.split(//).map(&:to_i).sum
end

def main
  fh=STDIN
  #fh=File.new("x.txt", "r")
  while fh.gets
    s = $_.chomp
    break if s=="0"
    puts aux(s)
  end

end

if $0 == __FILE__ then
  main
end


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

int main() {
	string s,t;
	cin>>s;
	cin>>t;
	int m=s.length();
	int n=t.length();
	int k=0;
	if(n==m+1)
	{
	for(int i=0;i<m;i++)
	{
	    if(t[i]==s[i])
	     k++;
	     
	    
	      
	      
	}
	    if(k==m)
	     cout<<"Yes"<<"\n";
	    else
	       cout<<"No"<<"\n";
	}
	
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    e = []
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = map(int,input().split())
        e.append(b)
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)

    col = 0
    for x in edge:
        col = max(col,len(x))
        
    print(col)
    ans = [-1 for _ in range(N)]
    go = [False for _ in range(N)]
    q = deque([0])
    while q:
        now = q.pop()
        go[now] = True
        c = 0
        for fol in edge[now]:
            if go[fol]:
                continue
            if c != ans[now]:
                ans[fol] = c
            else:
                ans[fol] = col-1
            c += 1
            q.append(fol)
    
    for i in range(N-1):
        print(ans[e[i]-1]+1)

if __name__ == "__main__":
    main()


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

int main(){
    int N,X,*m,i,sum=0,minm=1000,count;
    cin >> N >> X;
    m = new int[N];
    count = N;
    for(i=0;i<N;i++){
        cin >> m[i];
        sum += m[i];
        minm = min(minm,m[i]);
    }
    X -= sum;
    count += X / minm;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define INT_MAX 2147483647
#define INT_MIN -2147483648

typedef long long ll;			//%ld.
typedef long long int lli;		//%lld.
typedef unsigned long long ull;	//%llu.
// int %d, double %lf ,float %f ,string %s.

void swap(int *x,int *y);
int max(int x,int y);
int min(int x,int y);
void sortSeq(int dt[],int l,int r);
void sortIns(int dt[],int l,int r);
void mergeSort(int dt[],int l,int r);
int binser(int nilai,int dt[],int l,int r);
int abs(int x);
double maxD(double x,double y);
double minD(double x,double y);

//main code

int main(){
	char y,m[10],d[10];
	scanf("%[^/n]/%[^/]/%s",&y,&m,&d);
	printf("2018/%s/%s\n",m,d);

}

















///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double maxD(double x,double y){
	return x > y ? x : y;
}
double minD(double x,double y){
	return x < y ? x : y;
}
int abs(int x){
	if(x<0)	return -x;
	return x;
}
void merge(int arr[], int aLeft , int aRight , int bLeft , int bRight){ //merge
	int size = bRight - aLeft + 1;
	int temp[size];                
	int tIndex = 0;
	int aIndex = aLeft;
	int bIndex = bLeft;
	while( (aIndex <= aRight)&&(bIndex <= bRight))
	{
		if(arr[aIndex]<=arr[bIndex])
		{
			temp[tIndex] = arr[aIndex];
			aIndex = aIndex +1;
		}
		else
		{
			temp[tIndex] = arr[bIndex];
			bIndex = bIndex + 1;
		}
		tIndex = tIndex + 1;
	}
	while(aIndex <= aRight)
	{
		temp[tIndex] = arr[aIndex];
		aIndex = aIndex + 1;
		tIndex = tIndex + 1;
	}
	while(bIndex <= bRight)
	{
		temp[tIndex] = arr[bIndex];
		bIndex = bIndex + 1;
		tIndex = tIndex + 1;
	}
	for(int i = 0 ; i<= size-1 ; i++)
	{
		arr[aLeft + i] = temp[i];
	}
}

void swap(int *a,int *b){ //swap
	int temp = *a;
	*a = *b;
	*b = temp;
}
int max(int a,int b){ //maksimum
	return a>b ? a : b;
}
int min(int a,int b){ //minimum
	return a<b ? a : b;
}
void sortSeq(int arr[],int l,int r){ //sequencial sort
	for(int i=l;i<=r-1;i++)
		for(int j=i+1;j<=r;j++)
			if(arr[j]<arr[i])
				swap(&arr[i],&arr[j]);
}
void sortIns(int h[],int l,int r){ //insertion sort
	for(int i=l;i<=r;i++){
		int pos=i;
		while((pos>1)&&(h[pos]<h[pos-1])){
			swap(&h[pos],&h[pos-1]);
			pos=pos-1;
		}
	}
}
void mergeSort(int arr[],int left,int right){ //merge sort
	if( left == right )
		return; 
	else{
		int mid = (left+right)/2;    	 
		mergeSort(arr,left,mid);	
		mergeSort(arr,mid+1,right);
		merge(arr,left,mid,mid+1,right); 
	}
}
int binser(int x,int dt[],int kiri,int kanan){ //tidak ada = -1
	int hasil = -1;
	while((kiri<=kanan)&&(hasil==0)){
		int tengah=(kiri+kanan)/2;
		if(x<dt[tengah])
			kanan=tengah-1;
		else if(x>dt[tengah])
			kiri=tengah+1;
		else
			hasil=tengah;
	}
	return hasil;
}

Measured memory_bytes: 1704
def combination(array, comb_size):
  if comb_size == 0: return []
  if len(array) < comb_size: return []
  if len(array) == comb_size: return [array]
  if comb_size == 1: return map(lambda x: [x], array)
  ret = []
  for i in range(0, len(array) + 1 - comb_size):
    picked = array[i]
    rest = array[i + 1:]
    for c in combination(rest, comb_size - 1):
      ret.append([picked] + c)
  return ret

while True:
  n, x = map(int, input().split())
  if n == x == 0: break
  comb = combination([i for i in range(1, n + 1)], 3)
  print(str([sum(i) for i in comb].count(x)))


Measured memory_bytes: 36328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){
				int n = sc.nextInt(), s = sc.nextInt();
				if(n == 0 && s == 0) break;
				System.out.println(dfs(0, 0, s, n));
			}
		}
	}

	public static int dfs(int total, int addval, int target, int n){
		if(n <= 0) return total == target ? 1 : 0;
		else if(addval >= 10) return 0;
		else return dfs(total + addval, addval + 1, target, n - 1) + dfs(total, addval + 1, target, n);
	}

}

Measured memory_bytes: 26004
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]

def rec(i: int, a: int, b: int, c: int) -> int:
    if i == n:
        if a == 0 or b == 0 or c == 0:
            return float("inf")

        return abs(a-A)+abs(b-B)+abs(c-C)

    res = rec(i+1, a, b, c)

    res = min(res, rec(i+1, a+l[i], b, c) + (0 if a == 0 else 10))
    res = min(res, rec(i+1, a, b+l[i], c) + (0 if b == 0 else 10))
    res = min(res, rec(i+1, a, b, c+l[i]) + (0 if c == 0 else 10))

    return res

print(rec(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int kaijo (int n) {
    if (n == 1) return 1;

    return n * kaijo(n - 1);
}

int main (void) {
    int n, m;
    int i;

    scanf("%d %d", &n, &m);

    printf("%d", ((n * (n - 1)) / 2) + ((m * (m - 1)) / 2));

    return 0;
}



Measured memory_bytes: 1732
// B - Kagami Mochi
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	set<int> S;
	rpz(i, N){
		int d; cin>>d;
		S.insert(d);
	}
	cout<< S.size() <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)N;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline int getint(){
    int n;
    scanf("%d",&n);
    return n;
}

inline vector<int> getints(int n){
    vector<int> a(n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    return a;
}

void dumpints(vector<int> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  int N=getint();
  vector<int> L=getints(2*N);
  sort(ALL(L));
  int c=0;
  for(int i=0;i<N;i++){
    c+=L[2*i];
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])

Measured memory_bytes: 9188
# ABC 117 C

import sys

N, M = map(int, input().split())

if (N >= M):
    print(0)
    sys.exit(0)

x = list(map(int, input().split()))
x.sort()

diff = [0] * (M-1)

for i in range(len(x) -1):
    diff[i] = abs(x[i+1] - x[i])

diff.sort()
idx = len(diff) - N + 1
print(sum(diff[:idx]))


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    cout << N * 800 - (N / 15) * 200 << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<ll>().max();

int main() {
	string s;
	ll k;
	cin >> s >> k;
	ll n = s.size();

	char c = s[n-1];
	ll i=0;
	while (i<n and s[i] == c) {
		i++;
	}
	ll q = i-1;
	i=n-1;
	while (i>=0 and s[i] == c) {
		i--;
	}
	ll l = i+1;

	// l - k.
	ll sa = q+1;
	ll sb = n-l;

	ll ans = 0;
	if (!sa or !sb or k==1) {
		string t = s;
		ll ct = 0;
		for(ll i=0; i<n; i++) {
			if (t[i] == t[i+1]) {
				t[i+1] = '@';
				ct++;
			} 
		}
		ans = ct * k;
	} else {
		if (sa == n) {
			ans = (n * k) / 2;
		} else {
			ans = sa / 2 + sb / 2 + (k-1)*((sa + sb) / 2);
			ll ct = 0;
			for(ll i=q+1; i<l; i++) {
				if (s[i] == s[i+1]) {
					s[i+1] = '@';
					ct++;
				} 
			}
			ans += ct*k;
		}	
	}

	cout << ans << endl;
}


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

using namespace std;

int main()
{
	
	char a,b,c;
	scanf("%c",&a);
	getchar();
	scanf("%c",&b);
	getchar();
	scanf("%c",&c);
//	printf("%c%c%c",a,b,c);
	if((a=='5'&&b=='5'&&c=='7')||(a=='5'&&b=='7'&&c=='5')||(a=='7'&&b=='5'&&c=='5'))
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
// agc045_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int T;
    cin >> T;

    REP(_, T){
        int N;
        cin >> N;
        vector<ll> A(N);
        REP(i, N) cin >> A[i];
        string S;
        cin >> S;

        vector<ll> basis;
        int ans = 0;

        REP_REV(i, N){
            ll x = A[i];
            for (auto b: basis){
                x = min(x, x ^ b);
            }

            if (x != 0){
                if (S[i] == '0'){
                    basis.emplace_back(x);
                } else {
                    ans = 1;
                    break;
                }
            }
        }
        print(ans);
    }


    return 0;
}


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

using namespace std;
//TTTT-W-E-R-K

int hikari(int n,int k)
{
	if(n < k) return 0;
	if(n % k == 0) return n / k;
	return hikari(n - (n / k) - 1,k);
}

int tairitsu(int n,int k)
{
	if(n < k) return 0;
	if(n % k == 0) return n / k;
	int x = n / k * k;
	int shit = (n - x + (n / k)) / (n / k + 1);
	return tairitsu(n - shit * (n / k + 1),k);
}

int main()
{
	int as = 0;
	int T; scanf("%d",&T);
	while(T --)
	{
		int n,k; scanf("%d%d",&n,&k);
		if(k * 1ll * k >= n) as ^= tairitsu(n,k);
		else as ^= hikari(n,k);
	}
	printf("%s\n",as ? "Takahashi" : "Aoki");
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
    int key;
    Node *right, *left, *parent;
};
Node *root, *NIL;
Node *treeMinimum(Node *x) {
    while (x->left != NIL)x = x->left;
    return x;
}
Node *find(Node *u, int k) {
    while (u != NIL&&k != u->key) {
        if (k < u->key)u = u->left;
        else u = u->right;
    }
    return u;
}
Node *treeSuccessor(Node *x) {
    if (x->right != NIL)return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL&&x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}
void treeDelete(Node *z) {
    Node *y;
    Node *x;
    if (z->left == NIL || z->right == NIL)y = z;
    else y = treeSuccessor(z);
    if (y->left != NIL) {
        x = y->left;
    }
    else {
        x = y->right;
    }
    if (x != NIL) {
        x->parent = y->parent;
    }
    if (y->parent == NIL) {
        root = x;
    }
    else {
        if (y == y->parent->left) {
            y->parent->left = x;
        }
        else {
            y->parent->right = x;
        }
    }
    if (y != z)z->key = y->key;
    free(y);
}
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while (x != NIL) {
        y = x;
        if (z->key < x->key)x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if (y == NIL)root = z;
    else {
        if (z->key < y->key)y->left = z;
        else y->right = z;
    }
    return;
}
void inorder(Node *u) {
    if (u == NIL)return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
    return;
}
void preorder(Node *u) {
    if (u == NIL)return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
    return;
}
 
int main() {
    int n, i, x;
    string com;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'f') {
            cin >> x;
            Node *t = find(root, x);
            if (t != NIL)puts("yes");
            else puts("no");
        }
        else if (com == "insert") {
            cin >> x;
            insert(x);
        }
        else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if (com == "delete") {
            cin >> x;
            treeDelete(find(root, x));
        }
    }
    return 0;
}


Measured memory_bytes: 21900
def gcd(a, b)
  if (r = a % b) == 0
    return b
  else
    gcd(b, r)
  end
end

while line = gets do
  datas = line.split.map(&:to_i)
  datas.sort!
  g = gcd(datas[1], datas[0])
  l = datas[0] * datas[1] / g
  puts "#{g} #{l}"
end

Measured memory_bytes: 8648
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations
from itertools import accumulate
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7


def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]
lst=[0]*(10**5+1)
for i in range(10**5+1):
    if i%2==1:
        if is_prime(i) and is_prime((i+1)//2):
            lst[i]+=1

lst2=[0]
lst2.extend(accumulate(lst))
# print(lst2)
for i in range(q):
    print(lst2[lr[i][1]+1]-lst2[lr[i][0]])

Measured memory_bytes: 94168
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
map<int,int> grid;
map<int,int> :: iterator it;
int m[10];

 main() {
    //fr;fw;
    int h, w, n;
    cin >> h >> w >> n;
    int tot = (h-2)*(w-2);
    REP(z,n){
      int a, b;
      cin >> a >> b;
      a--;b--;
      REP(i,3){
        REP(j,3){
          int x = a-i, y = b-j;
          int p = x+2, q=y+2;
          if(x >=0 && y >= 0 && p < h && q <w){
           // cout << z <<": "<< x <<" "<<y <<" "<<p <<" "<<q <<" " <<x*(w-2)+y+1<<"\n";
            grid[x*(w-2)+y+1]++;
          }
        }
      }
    }
    int sz = grid.size();
    for(it = grid.begin(); it!=grid.end();it++){
      if(it->S <10){
        m[it->S]++;
      }
    }
    m[0] = tot - sz;
    REP(i,10) cout << m[i] <<"\n";
    return 0;
}

Measured memory_bytes: 56448
#include<stdio.h>
int main(){
int a[13][32],i,b=4,c,d;
for(i=1;i<32;i++){
if(b==8){
b=1;
a[1][i]=b;
}
else{
a[1][i]=b;
}
b++;
}
for(i=1;i<30;i++){
if(b==8){
b=1;
a[2][i]=b;
}
else{
a[2][i]=b;
}
b++;
}
for(i=1;i<32;i++){
if(b==8){
b=1;
a[3][i]=b;
}
else{
a[3][i]=b;
}
b++;
}
for(i=1;i<31;i++){
if(b==8){
b=1;
a[4][i]=b;
}
else{
a[4][i]=b;
}
b++;
}
for(i=1;i<32;i++){
if(b==8){
b=1;
a[5][i]=b;
}
else{
a[5][i]=b;
}
b++;
}
for(i=1;i<31;i++){
if(b==8){
b=1;
a[6][i]=b;
}
else{
a[6][i]=b;
}
b++;
}
for(i=1;i<32;i++){
if(b==8){
b=1;
a[7][i]=b;
}
else{
a[7][i]=b;
}
b++;
}
for(i=1;i<32;i++){
if(b==8){
b=1;
a[8][i]=b;
}
else{
a[8][i]=b;
}
b++;
}
for(i=1;i<31;i++){
if(b==8){
b=1;
a[9][i]=b;
}
else{
a[9][i]=b;
}
b++;
}
for(i=1;i<32;i++){
if(b==8){
b=1;
a[10][i]=b;
}
else{
a[10][i]=b;
}
b++;
}
for(i=1;i<31;i++){
if(b==8){
b=1;
a[11][i]=b;
}
else{
a[11][i]=b;
}
b++;
}
for(i=1;i<32;i++){
if(b==8){
b=1;
a[12][i]=b;
}
else{
a[12][i]=b;
}
b++;
}
while(1){
scanf("%d %d\n",&c,&d);
if(c==0 && d==0){
break;
}
else{
if(a[c][d]==1){
printf("Monday\n");
}
else if(a[c][d]==2){
printf("Tuesday\n");
}
else if(a[c][d]==3){
printf("Wednesday\n");
}
else if(a[c][d]==4){
printf("Thursday\n");
}
else if(a[c][d]==5){
printf("Friday\n");
}
else if(a[c][d]==6){
printf("Saturday\n");
}
else if(a[c][d]==7){
printf("Sunday\n");
}
}
}
return 0;
}




Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n>>x>>y;
	for(ll i=1;i<=n;i++){
		k=i;
		sum=0;
		while(k){
			sum+=(k%10);
			k/=10;
		}
		if(x<=sum && sum<=y)ans+=i;
	}
	cout<<ans<<nw;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  if(s.size()<4){
    cout<<"No"<<endl;
    return 0;
  }
  string t=s.substr(0,4);
  if(t=="YAKI")cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1		1000000007
#define MOD2		998244353
#define BOOST		ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;


int main()
{
    ll n, k;
    cin >> n >> k;

    cout << min(n%k, k - n%k);


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);


int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> l(n+1, vector<ll>());
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        l[a].push_back(b);
        l[b].push_back(a);
    }

    vector<ll> dist(n+1, -1);
    vector<ll> sirube(n+1, -1);
    queue<ll> que;

    dist[1] = 0;
    que.push(1);

    while(!que.empty()){
        ll v = que.front();
        que.pop();

        for(auto nv : l[v]){
            if(dist[nv] != -1) continue;
            dist[nv] = dist[v]++;
            sirube[nv] = v;
            que.push(nv);
        }
    }

    bool z = true;
    rep(i, n+1){
        if(i == 0 || i == 1) continue;
        if(sirube[i] == -1){
            z = false;
            break;
        }
    }
    if(z){
        cout << "Yes" << endl;
        rep(i, n+1){
            if(i == 0 || i == 1) continue;
            cout << sirube[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 13632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        var prime = PrimeFact(N);
        var prime2 = new Dictionary<long, long>();
        foreach(var p in prime)
        {
            if (prime2.ContainsKey(p))
            {
                prime2[p]++;
            }
            else
            {
                prime2[p] = 1;
            }
        }
        long ans = 0;
        foreach (var x in prime2.Values)
        {
            var temp = x;
            var count = 0;
            for(var i=1; ; i++)
            {
                temp = temp - i;
                if (temp >= 0) count++;
                else break;
            }
            ans += count;
        }
        Console.WriteLine(ans);
    }
    static IEnumerable<long> PrimeFact(long n)
    {
        var temp = n;
        long p = 2;
        while (p * p <= n)
        {
            if (temp % p == 0)
            {
                temp /= p;
                yield return p;
            }
            else
            {
                p++;
            }
        }
        if (temp != 1) yield return temp;
    }
}

Measured memory_bytes: 27860
<?php
declare(strict_types=1);
fscanf(STDIN, "%d%d%d", $l, $r, $d);

$lists = [];
for ($i = $l; $i <= $r; $i++) {
    if ($i % $d == 0) {
        array_push($lists, $i);
    }
}
echo count($lists);

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;

    ll x = N;
    if (N >= B) x = B - 1;
    ll ans = (A * x) / B - A * (x / B);

    cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n, v;
  double  a, b,c;
  cin >> n;
  std::priority_queue<double,                 // 要素の型はint
      std::vector<double>,   // 内部コンテナはstd::vector (デフォルトのまま)
      std::greater<double>   // 昇順 (デフォルトはstd::less<T>)
  > que;
  rep(i,n)
  {
    cin >> v;
    que.push(v);
  }
  while (!que.empty()) {
    a = que.top();
    que.pop();
    b = que.top();
    que.pop();
    c = (a + b) / (double)2;
    if (!que.empty()) {
      que.push(c);
    }
  }
  cout << c;
  return 0;
}


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

using namespace std;

int main(){
    int64_t n;
    cin >> n;
    int64_t ans = n - 1;

    for (int64_t i = 1; i * i <= n; i++){
        if (n % i != 0)
            continue;
        ans = min(ans, i + n / i - 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int main(void){
    /* 変数の宣言 */
  int AB, BC, CA, result;
  scanf("%d%d%d" , &AB , &BC, &CA);
  result = abs(AB)* abs(BC)/2;
  printf("%d",result);
  return 0;
}

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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        char[] s = in.s().toCharArray();
        int N = s.length;
        int a = -1;
        int b = -1;
        for(int i = 0; i < N-2; i++){
            if(s[i] == s[i+1]){
                a = i+1;
                b = i+2;
                break;
            } else if (s[i] == s[i+2]){
                a = i+1;
                b = i+3;
                break;
            }
        }
        if(s[N-2] == s[N-1]){
            a = N-1;
            b = a+1;
        }
        out.println(a+" "+b);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 23124
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while True:
    a, b = b%a, a
    if a == 0:
      return b

def lcm(a, b):
  return int(a * b // gcd(a, b))


def main():
  n, m = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  x = 1
  for i in range(len(As)):
    x = lcm(x, As[i])
    if m/x < 0.5:
      print(0)
      return
  if sum([(x//A)%2 == 1 for A in As]) == len(As):
    print(int(m/x-0.5+1))
  else:
    print(0)

if __name__=='__main__':
  main()

Measured memory_bytes: 15060
using System;

namespace ABC048B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = long.Parse(input[0]);
            var b = long.Parse(input[1]);
            var x = long.Parse(input[2]);
            if (a == 0)
            {
                var answer = (b / x) + 1;
                Console.WriteLine(answer);
            }
            else
            {
                var answer = (b / x) - ((a - 1) / x);
                Console.WriteLine(answer);
            }
        }
    }
}


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

int main(){
  int i,j;ll cnt=0;
  int n;
  cin>>n;
  int a[n+1];
  for(i=1;i<=n;i++)cin>>a[i];
  int c[n];
  for(i=n;i>=1;i--){
    if(a[i]!=0){
      c[cnt++]=i;
      int p=(int)round(sqrt(i));
      if(p*p==i)a[p]=1-a[p];
      for(j=1;j<=p;j++){
        if(i%j==0){
          a[j]=1-a[j];
          a[i/j]=1-a[i/j];
        }
      }
    }
  }
  cout<<cnt<<endl;
  for(i=0;i<cnt;i++)cout<<c[i]<<" ";
}

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

int main()
{
    int a, b;
    while(~scanf("%d %d",&a,&b))
    {
        int temp = a * b;
        if(temp & 1)
        {
            printf("Odd\n");
        }
        else
        {
            printf("Even\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int a, b, c;

  cin >> a >> b >> c;

  printf("%d\n", max({a*10 + b + c, b*10 + a + c, c*10 + a + b}));
  
  return 0;
}



Measured memory_bytes: 256
H,W = map(int,input().split())
L = [list(map(int,input().split())) for i in range(H)]

answer = []

for i in range(H):
    l = L[i]
    if i < H-1:
        if i%2==0:
            for j in range(W):
                if l[j]%2==1:
                    l[j] -= 1
                    if j==W-1:
                        answer.append( (i,j,i+1,j) )
                        L[i+1][j] += 1
                    else:
                        answer.append( (i,j,i,j+1) )
                        l[j+1] += 1
        else:
            for jj in range(W):
                j = (W-1)-jj
                if l[j]%2==1:
                    l[j] -= 1
                    if j==0:
                        answer.append( (i,j,i+1,j) )
                        L[i+1][j] += 1
                    else:
                        answer.append( (i,j,i,j-1) )
                        l[j-1] += 1
    else:
        if i%2==0:
            for j in range(W):
                if l[j]%2==1:
                    l[j] -= 1
                    if j==W-1:
                        continue
                    else:
                        answer.append( (i,j,i,j+1) )
                        l[j+1] += 1
        else:
            for jj in range(W):
                j = (W-1)-jj
                if l[j]%2==1:
                    l[j] -= 1
                    if j==0:
                        continue
                    else:
                        answer.append( (i,j,i,j-1) )
                        l[j-1] += 1
                    
print(len(answer))
for a in answer:
    print('%d %d %d %d' % (a[0]+1,a[1]+1,a[2]+1,a[3]+1))




Measured memory_bytes: 22340
#include <stdio.h>
#define exchange(a,b) do{__typeof(a) __t; __t=a; a=b; b=__t;}while(0)
#define parent(i) (i/2)
#define left(i) (i*2)
#define right(i) (i*2+1)
#define MAX_N 500001
 
int N;
int heap[MAX_N];
 
void maxHeapify(int A[], int i) {
  int l = left(i);
  int r = right(i);
  int largest;
  if(l <= N && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if(r <= N && A[r] > A[largest]) {
    largest = r;
  }
  if(largest != i) {
    exchange(A[i], A[largest]);
    maxHeapify(A, largest);
  }
}
 
void buildMaxHeap(int A[]) {
  int i;
  for(i = N/2; i >= 1; --i) {
    maxHeapify(A, i);
  }
}
 
int main() {
  int i;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d", heap + 1 + i);
  }
  buildMaxHeap(heap);
  for(i = 0; i < N; ++i) {
    printf(" %d", heap[i+1]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        var count = int.Parse(Console.ReadLine());

        var inputs = new List<int[]>();
        foreach (var i in Enumerable.Range(0, count))
        {
            inputs.Add(Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x)));
        }

        foreach (var x in inputs)
        {
            Array.Sort(x);
            Console.WriteLine( (x[0] * x[0] + x[1] * x[1] == x[2] * x[2])? "YES" : "NO");
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

struct edge{
  ll f,t,c;
};

ll n,m;
ll cnt = 101010;
vector<edge> es;
vector< vector<P> > g(cnt);
vector<bool> used(cnt);
Vector d(cnt);

int main(){
  cin >> n >> m;
  rep(i,m){
    ll a,b,c;
    cin>> a >> b >> c;
    a--;
    b--;
    g[a].pb(P(b,c));
    used[b] = true;
    es.pb(edge{a,b,c});
  }
  priority_queue<P, vector<P>, greater<P> > que;
  rep(i,n){
    d[i] = INF;
    if(used[i])continue;
    que.push(P(0,i));
  }
  while(que.size() > 0){
    ll v = que.top().se;
    ll nd = que.top().fi;
    que.pop();
    if(d[v] != INF)continue;
    d[v] = nd;
    each(e,g[v])que.push(P(nd+e.se, e.fi));
  }
  bool ok = true;
  rep(i,m){
    ll v = es[i].f, u = es[i].t, nc = es[i].c;
    if(d[v] + nc != d[u])ok = false;
  }
  if(ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 17576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll calc(ll x,ll y) {
    if(y==0) return -x;
    return calc(y,x%y)+(x/y)*2*y;
}
int main() {
    ll n,x;cin>>n>>x;
    printf("%lld\n",calc(max(x,n-x),min(x,n-x))+n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<set<int>>cycle(50,set<int>{});
vector<vector<int>>g(50,vector<int>(0));
int pushed[50];
int res = 0;

void dfs(int start, int leve,int i,vector<bool>visited){
    visited[i]=true;
    for(int j=0; j<g[i].size();j++){
        if(!(visited[g[i][j]])){
            dfs(start,leve+1, g[i][j],visited);
            

        }
        if(leve>1 && g[i][j]==start)
        {
            cycle[min(start,i)].insert(max(start,i));
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }

    for(int i=0;i<n;i++){
        vector<bool>visited(50,false);
        visited[i]=true;
        dfs(i,0,i,visited);
    }
    for(int i=0; i<n;i++){
        for(auto itr=cycle[i].begin(); itr!=cycle[i].end();itr++){
            m--;
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3628
n=int(input())
s=[]
for i in range(n):
    s.append(input())
l = ["AC","WA","TLE","RE"]
cnt=[0,0,0,0]
for i in range(n):
    index=l.index(s[i])
    cnt[index]+=1
for i in range(4):
    print("{0} x {1}".format(l[i],cnt[i]))

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


int main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d;

    if(c % b == 0)e = c / b;
    else e = c / b + 1; 
    if(a % d == 0)f = a / d;
    else f = a / d + 1; 

    if(e > f)cout << "No" << endl;
    if(e <= f)cout << "Yes" << endl;
}

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

public class Main{
  public static boolean kaibun(String s){
  StringBuffer sb=new StringBuffer(s);
  sb.reverse();
  String t=sb.toString();
  return t.equals(s);
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	String s=sc.next();
    int n=s.length();
    char[] a;
    a=s.toCharArray();
    String x="",y="";
    for(int i=0;i<(n-1)/2;i++){
      x+=a[i];
      y+=a[(n+1)/2+i];
    }
    if(kaibun(s)&&kaibun(x)&&kaibun(y)){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
    
  }
}

Measured memory_bytes: 23892
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 7;


int main()
{
	speed;
	int n, m;
	cin >> n >> m;
	string a(n, '0' + m), b(m, '0' + n);
	if ( a < b ) cout << a;
	else cout << b;
	time;
}


Measured memory_bytes: 256
nrow, col = [], []

n, m = map(int, input().split())
count = 0
while count < n:
    nrow.append(list(map(int, input().split())))
    count += 1
count = 0
while count < m:
    col.append(int(input()))
    count += 1

for i in range(n):
    sum = 0
    for j in range(m):
        sum += nrow[i][j] * col[j]
    print(sum)



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

int main(){ 
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N;
int dp[100100];
int h[100100];

int main(){
  cin >> N;
  for(int i=0;i<N;i++) dp[i]=100000;
  for(int i=0;i<N;i++) cin >> h[i];

  dp[0]=0;
  for(int i=1;i<N;i++){
    int a=dp[i-1]+abs(h[i-1]-h[i]);
    int b=i==1?100000:dp[i-2]+abs(h[i-2]-h[i]);
    dp[i]=min(a,b);
  }
  cout << dp[N-1] << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  string s;
  int cnt=0,n;
  cin >> n >> s;
  rep(i,n-2){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') cnt++;
  }
  cout << cnt;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		int sSize = s.length();

		String tMinus1 = t.substring(0, sSize);

		if (tMinus1.equals(s)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}
}


Measured memory_bytes: 35764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#define inf 10e8
#define rep(i,n) for(long i=0;i<n;i++)
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<long> vec(m);
    long num[n+10];
    num[1]=2;num[2]=5;num[3]=5;num[4]=4;num[5]=5;num[6]=6;num[7]=3;num[8]=7;num[9]=6;
    rep(i,m) cin >> vec[i];
    //dp 桁数
    long dp[n+10];
    dp[0]=0;dp[1]=-inf;
    for(int i=2;i<=n;i++){
        long counter;
        dp[i]=-inf;
        for(int j=0;j<m;j++){
            long honsuu=0;
            counter=i-num[vec[j]];
            if(counter<0) {
                honsuu=-inf;
            }
            else{
                honsuu=dp[counter]+1;
            }
            dp[i]=max(dp[i],honsuu);
        }
    }
    
    //making
    queue<long> que;
    sort(vec.begin(),vec.end(),greater<int>());
    long e=n;
    while(e>0){
        for(int i=0;i<m;i++){
            if(e-num[vec[i]]<0) continue;
            else if(dp[e]-1==dp[e-num[vec[i]]]){
                que.push(vec[i]);
                e=e-num[vec[i]];
                break;
            }
        }
    }
    ostringstream ans;
    
    while(!que.empty()){
        long d=que.front();
        que.pop();
        ans << d;
    }
    printf("%s\n",ans.str().c_str());
}




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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < int(n); i++)

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;

int n;
ll a[3001];
ll prefix[3001];
ll dp[3001][3001];

ll sum(int i, int j) {
    return (prefix[j] - prefix[i - 1]);
}

int main() {
    IOS;
    cin >> n;
    rep(i, n) cin >> a[i + 1];
    for(int i = 1; i <= n; i++) prefix[i] = prefix[i - 1] + a[i];
    rep(i, n + 1) dp[i][i] = a[i];
    for(int len = 1; len <= n - 1; len++) {
        for(int i = 1; i <= n - len; i++) {
            int j = i + len;
            dp[i][j] = max(a[i] + sum(i + 1, j) - dp[i + 1][j],
                           a[j] + sum(i, j - 1) - dp[i][j - 1]);
        }
    }

    cout << dp[1][n] - (prefix[n] - dp[1][n]);
    return 0;
}

Measured memory_bytes: 70016
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if (a * b == 2) { cout << 3; }
    if (a * b == 3) { cout << 2; }
    if (a * b == 6) { cout << 1; }

    return 0;
}


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

int main(){
  int X, a, b, c, d;
  cin >> X;
  a = X / 1000;
  b = (X - a * 1000) / 100;
  c = (X - a * 1000 - b * 100) / 10;
  d = X - a * 1000 - b * 100 - c * 10;
  if ( (a==b && b==c) || (b==c && c==d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
    

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

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

  vector<pair<int,int>> A(N);
  for(int i = 0;i < N;i++) {
    int a;
    cin >> a;
    A.at(i) = make_pair(a,i);
  }

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

  for(int i = 0;i < N;i++) {
    cout << A.at(i).second+1 << " ";
  }

  cout << endl;


}



Measured memory_bytes: 1664