akhauriyash/Code-Regression huggingface dataset:
#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 ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> que;
  REP(i, n) {
    ll a;
    cin >> a;
    que.push(a);
  }
  REP(i, m) {
    ll t = que.top();
    que.pop();
    t /= 2;
    que.push(t);
  }
  ll ans = 0;
  REP(i, n) {
    ll t = que.top();
    que.pop();
    ans += t;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1400
import os
import sys
from io import BytesIO, IOBase
# from collections import defaultdict as dd
# from collections import deque as dq
# import itertools as it
# from math import sqrt, log, log2
# from fractions import Fraction

def main():
    t = 1
    for _ in range(t):
        # n = int(input())
        n, d = map(int, input().split())
        c = 0
        for i in range(n):
            x, y = map(int, input().split())
            if (x**2 + y**2) <= d**2:
                c +=1
        print(c)

        

        


        #nums = list(map(int, input().split()))
        




































# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 77284
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A_i = []
    for i in range(N):
        A_i.append(long(input_raw[i]) - i)


    ave_A = (sum(A_i)/N)
    A_i.sort()
    
    b1 = (ave_A)
    b2 = ave_A + 1
    b3 = A_i[N/2]
    b4 = b3
    b5 = -b1
    b6 = -b2
    score1 = 0L
    score2 = 0L
    score3 = 0L
    score4 = 0L
    score5 = 0L
    score6 = 0L
    for i in range(N):
        score1 += abs(b1 - A_i[i])
        score2 += abs(b2 - A_i[i])
        score3 += abs(b3 - A_i[i])
        score4 += abs(b4 - A_i[i])
        score5 += abs(b5 - A_i[i])
        score6 += abs(b6 - A_i[i])

    print min(score1, score2, score3, score4,score5,score6)




if __name__ == '__main__':
    main()


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

int debug = 0;

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(debug){
        cout << "dfs:";
        for(auto x:A){
            cout << x << ",";
        }
        cout << endl;
    }
    if(A.size() == n+1){
        int now = 0;
        rep(i,q){
            if(A[b[i]]- A[a[i]]== c[i]) now +=d[i];
        }
        ans = max(ans, now);
        return;
    } 

    A.push_back(A.back());
    while(A.back() <=m){
        dfs(A);
        A.back()++;
    }

}

int main(){
    cin >> n >>m>>q;
    a = b = c = d = vector<int>(q);
    rep(i,q){
        cin >> a[i] >> b[i]>> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>

using namespace std;

struct Array{
	long long a;
	long long b;
};

int main(){
	long long n, k;
	cin >> n >> k;
	Array *p = new Array[n];
	for( long long i=0; i<n; i++ ) {
		cin >> p[i].a >> p[i].b;
	}
	sort(p, p+n, [](Array n1, Array n2){
		return n1.a<n2.a;
	});
	long long sum = 0;
	for( long long i=0; i<n; i++ ) {
		sum += p[i].b;
		if( sum>=k ) {
			cout << p[i].a << endl;
			break;
		}
	}

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int w = in.nextInt();
        int n = in.nextInt(); in.nextLine();
        int[] a = new int[w];
        for(int i = 0; i < w; i++){
            a[i] = i + 1;
        }
        for(int i = 0; i < n; i++){
            String[] line = in.nextLine().split(",");
            int s = Integer.parseInt(line[0]) - 1;
            int t = Integer.parseInt(line[1]) - 1;
            int tmp = a[s]; a[s] = a[t]; a[t] = tmp;
        }

        for(int i: a){
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n;
    cin >> n;
    vi a(n);
    vl l(n+1,0);
    rep(i,n){
        cin >> a[i];
        l[a[i]]++;
    }
    //for(auto it:l)cout << it << endl;
    ll sum = 0; 
    rep1(i,n+1){
        sum += l[i]*(l[i]-1)/2;
        //cout << sum << endl;
    }
    rep(i,n){
        ll x = l[a[i]];
        ll y = x*(x-1)/2;
        --x;
        ll z = sum - y + x*(x-1)/2;
        cout << z << endl; 
    }
    return 0;

}


Measured memory_bytes: 4992
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			double r = sc.nextDouble();
			double ret = 0.00;
			
			ret = 2*3.141592*r;
			
			System.out.println(ret);
			
		}
	}

Measured memory_bytes: 37380
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


typedef complex<double> Point;

int N;
double D,NUM = 360.0;
Point CENTER,A;


void func(){

	CENTER = Point(0,0);
	A = Point(0,1);

	double L,R,move_time,L_deg,R_deg,theta,tmp;

	Point base,B;

	for(int loop = 0; loop < N; loop++){

		scanf("%lf %lf %lf",&L_deg,&R_deg,&move_time);

		if(L_deg == 0 && R_deg == 0)continue;

		L = 2.0*M_PI*(fabs(L_deg)/NUM)*move_time;
		R = 2.0*M_PI*(fabs(R_deg)/NUM)*move_time;

		if(L_deg == R_deg){

			if(L_deg > 0){

				CENTER += L*A;

			}else{

				CENTER -= L*A;
			}
			continue;
		}

		B = A*Point(0,-1);

		if(L_deg == 0){

			base = CENTER-D*B;
			theta = R/(2*D);

			if(R_deg < 0){
				theta *= -1;
			}

		}else if(R_deg == 0){

			base = CENTER+D*B;
			theta = L/(2*D);

			if(L_deg > 0){
				theta *= -1;
			}

		}else if(L_deg*R_deg > 0){

			if(L > R){
				tmp = 2*D*R/fabs(L-R);
				base = CENTER+(D+tmp)*B;

				theta = R/tmp;

				if(L_deg > 0){
					theta *= -1;
				}

			}else{
				tmp = 2*D*L/fabs(L-R);
				base = CENTER-(D+tmp)*B;

				theta = L/tmp;

				if(L_deg < 0){
					theta *= -1;
				}
			}

		}else{

			tmp = 2*D*R/(L+R);
			base = CENTER+(D-tmp)*B;

			theta = R/tmp;

			if(L_deg > 0){
				theta *= -1;
			}
		}

		 CENTER = (CENTER-base)*exp(Point(0,theta))+base;
		 A *= exp(Point(0,theta));
	}

	printf("%.10lf\n%.10lf\n",CENTER.real(),CENTER.imag());
}

int main(){

	while(true){
		scanf("%d %lf",&N,&D);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  int X, K=2;
  static const double pi = 3.141592653589793;
  cin >> X;
 
  float x = 0.0, y = 1.0, theta;
  while (true) {
    theta = float(X*(K-1)*pi) / 180.0;
    x += sin(theta);
    y += cos(theta);
    if (x < 0.001 && x > -0.001 && y < 0.001 && y > -0.001){
      break;
    }
    K++;
  }
  cout << K;
}

Measured memory_bytes: 3772
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int a = 0, b = 0;
    cin >> a >> b;
    int ans = 0;
    while (a <= b) {
        string s = to_string(a);
        string t = to_string(a);
        reverse(t.begin(), t.end());
        if (s == t) ans++;
        a++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define N 310
double f[N][N][N];
ll n;
int main(){
    cin>>n;
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)for(int k=0;k<=n;k++){
     if(i==0&&j==0&&k==0){
      f[i][j][k]=0;
      continue;
     }
     double cur=n/(double)(i+j+k);
     if(i)cur+=f[i-1][j+1][k]*(i)/(double)(i+j+k);
     if(j)cur+=f[i][j-1][k+1]*(j)/(double)(i+j+k);
     if(k)cur+=f[i][j][k-1]*(k)/(double)(i+j+k);
     f[i][j][k]=cur;
    }
    ll a=0,b=0,c=0;
    for(int i=0;i<n;i++){
     ll x;cin>>x;
     if(x==1)a++;
     if(x==2)b++;
     if(x==3)c++;
    }
    cout<<fixed<<setprecision(9)<<f[c][b][a]<<endl;
 return 0;   
}

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

int main(){
  int n,s;
  cin>>n;
  vector<int> a(1000000);
  for(int i=0;i<n;i++){
    cin>>s;
    if (s!=0){
      a.at(s-1)++;
    }
    a.at(s)++;
    a.at(s+1)++;
  }
  sort(a.begin(),a.end(),greater<int>());
  cout<<a.at(0);    
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[200110];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[2][66];

P u[555551];
priority_queue<P> q;
//stack<int> s;
set<int> s;
map<int,int> p;
vector<int> v;

bool as(P a,P b)
{
  return a.x<b.x;
}

P mm(P a,P b)
{
  P k;
  if(o[a.x]<o[b.x]) k.x=a.x;
  else k.x=b.x;
  if(o[a.y]<o[b.y]) k.y=a.y;
  else k.y=b.y;
  return k;
}

int f(int n,int m)
{
  n++,m--;
  int p=n;
  P k={0,0};
  for(;n<m;)
  {
    if(n%2) k=mm(k,u[n++]);
    else if(m%2==0) k=mm(k,u[m--]);
    else n/=2,m/=2;
  }
  //printf("!!%d %d %d\n",i,mm(k,u[n]).x,mm(k,u[n]).y);
  if(p%2) return mm(k,u[n]).x;
  return mm(k,u[n]).y;
}

int main()
{
  scanf("%d",&a);
  for(i=1;i<a;i*=2);
  o[0]=mod;
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&n);
    o[t]=n;
    if((t+i-1)%2) u[t+i-1]={t,0};
    else u[t+i-1]={0,t};
  }
  for(int t=i-1;t;t--)
  u[t]=mm(u[t*2],u[t*2+1]);
  s.insert(0);
  s.insert(a+1);
  e=f(i-1,a+i);
  q.push({e,o[e]});
  for(;q.size();)
  {
    P k=q.top();
    q.pop();
    printf("%d ",k.y);
    m=f(k.x+i-1,(*s.upper_bound(k.x))+i-1);
    printf("%d ",o[m]);
    s.insert(k.x);
    s.insert(m);
    if(k.x+1<m)
    {
      d=f(k.x+i-1,m+i-1);
      //puts("#");
      //printf("@@%d %d %d\n",d,k.x,m);
      q.push({d,o[d]});
    }
    set<int>::iterator c=s.find(k.x);
    c--;
    if((*c)+1<k.x)
    {
      //puts("$");
      d=f((*c)+i-1,k.x+i-1);
      q.push({d,o[d]});
    }
    c=s.find(m);
    c++;
    if(m+1<(*c))
    {
      //puts("$");
      d=f(m+i-1,(*c)+i-1);
      q.push({d,o[d]});
    }
  }
}


Measured memory_bytes: 16120
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

int cmp_count = 0;


void merge(int A[],int left,int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  INT_MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
			cmp_count++;
		}else{
			A[k] = R[j++];
			cmp_count++;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

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

	mergeSort(S,0,n);

	for(int i = 0; i < n-1; i++) printf("%d ",S[i]);
	printf("%d\n",S[n-1]);
	printf("%d\n",cmp_count);

}



Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define reverse(vec) reverse(vec.begin(),vec.end())
#define unsort(vec); sort(vec);reverse(vec);
#define int long long
#define inf 1000000007

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x/gcd(x,y)*y;
}
 
signed main(){
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1)cout<<0<<endl;
	else if(abs(n-m)==0){
		int ans=1;
		for(int i=1;i<=n;i++){
			ans*=i;
			if(ans>=inf){
				ans%=inf;
			}
		}
		int x=ans*ans%inf*2%inf;
		cout<<x<<endl;
	}
	else{
		int ans=1;
		for(int i=1;i<=min(n,m);i++){
			ans*=i;
			if(ans>=inf){
				ans%=inf;
			}
		}
		int x=ans*ans%inf*max(n,m)%inf;
		cout<<x<<endl;
	}
}


Measured memory_bytes: 256
s=input()
n=len(s)

res='WA'
cnt=0
cnt2=0

if s[0]=='A':
	for i in range(2,n-1):
		if s[i]=='C':
			cnt+=1
	for i in range(1,n):
		if s[i].isupper() and s[i]!='C':
			cnt2+=1
	if cnt==1 and cnt2==0:
		res='AC'
        
print(res)

Measured memory_bytes: 3064
N = int(input())
s = input()
s = s[1:] + s[0]
ans = []
for i, j in [('S', 'S'), ('S', 'W'), ('W', 'S'), ('W', 'W')]:
    ans = [i, j]
    for si in s:
        if ans[-1] == 'S':
            if si == 'o':
                ans.append(ans[-2])
            else:
                ans.append('W' if ans[-2] == 'S' else 'S')
        else:
            if si == 'o':
                ans.append('W' if ans[-2] == 'S' else 'S')
            else:
                ans.append(ans[-2])
    if ans[:2] == ans[-2:]:
        print(''.join(ans[:-2]))
        break
else:
    print(-1)

Measured memory_bytes: 4868
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    a, b, c = LI()
    rest = a - b
    if rest >= c:
        print(0)
    else:
        print(c-rest)

solve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
    int n, k, t;
    int min = 1;
    int cnt = 0;
    int index = 0;
    cin >> n >> k;
    vector<int> vec;
    for (int i = 0; i < n; i++) cin >> t;
    for (int i = 0; i < n; i++) {
      cnt++;
      if(n <= k + (k - 1) * (cnt - 1)) break;
    }
    cout << cnt << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define orep(i, n) for (int i = 1; i < (int)(n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int r;
  cin >> r;
  cout << r * r << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  const i32 mod = 1000000007;
  i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));
  dp[0] = 1;
  for (i32 i = 1; i <= k; ++i) {
    for (i32 j = i; j <= n; ++j) {
      dp[j] += dp[j - i];
      dp[j] %= mod;
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 2148
#include<stdio.h>
int main(void)
{
    int N,x;

    scanf("%d %d",&N,&x);
    if (N <= 2) {
        if (x == N) {
            printf("Yes\n");
            for (int i = 0; i < 2*N-1; i++) {
                printf("%d\n",i+1);
            }
        } else {
            printf("No\n");
        }
    } else  {
        if (x >= 2 && x <= 2*N-2) {
            printf("Yes\n");
            if (x == 2) {
                for (int i = 0; i < N-3; i++) {
                    printf("%d\n",i+4);
                }
                printf("3\n");
                printf("2\n");
                printf("1\n");
                printf("%d\n",2*N-1);
                for (int i = N+1; i < 2*N-1; i++){
                    printf("%d\n",i);
                }
            } else {
                int count = 3;
                for (int i = 0; i < N-3; i++) {
                    if (count==x) count++;
                    printf("%d\n",count);
                    count++;
                }
            printf("2\n");
                printf("%d\n",x);
                printf("%d\n",2*N-1);
                printf("1\n");
                for (int i = N+1; i < 2*N-1; i++) {
                    if (count==x) count++;
                    printf("%d\n",count);
                    count++;
                }
            }
        } else {
            printf("No\n");
        }
    }    
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int h, w;
  cin >> h >> w;
  int d[10][10];
  for(int i = 0; i < 10; ++i) for(int j = 0; j < 10; ++j)
  {
    cin >> d[i][j];
  }

  int min_cost[10] = { 0, 0, };
  fill(min_cost + 2, min_cost + 10, 1000);

  for (int k = 0; k < 10; k++){			// 経由する頂点
    for (int i = 0; i < 10; i++) {		// 始点
      for (int j = 0; j < 10; j++) {	// 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int num;
  ll ans = 0;
  for(int i = 0; i < h; ++i) for(int j = 0; j < w; ++j)
  {
    cin >> num;
    num = abs(num);
    ans += d[num][1];
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N, 0);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int count = 1, now = 0;
  for (int i = 0; i < N-1; i++) {
    if (vec.at(i) > vec.at(i+1)) {
      count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >>m;
    vstr s(n);
    rep(i,n) cin >> s[i];

    rep(i,n){
        bool comp=true;
        rep(j,m){
            if(s[i][j]=='#') comp=false;
        }
        if(comp){
            rep(j,m) s[i][j]='x';
        }
    }

    rep(i,m){
        bool comp=true;
        rep(j,n){
            if(s[j][i]=='#') comp=false;
        }
        if(comp){
            rep(j,n) s[j][i]='x';
        }
    }
    rep(i,n){
        
        rep(j,m){
            if(s[i][j]!='x')cout<<s[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3652
# coding: utf-8
S=list(input())
T=list(input())
flg=False
S.reverse()
T.reverse()

for i in range(max(0,len(S)-len(T)+1)):
    flg=True
    for j in range(len(T)):
        if not(S[i+j]=="?"):
            if S[i+j]!=T[j]:
                flg=False
    if flg:
        for k in range(len(T)):
            S[i+k]=T[k]
        break    
        

S.reverse()

for i in range(len(S)):
    if S[i]=="?":
        S[i]="a"
if flg:
    print("".join(S))
else:
    print("UNRESTORABLE")



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N; cin >> N;
  vector<int> d(N); cin >> d;
  sort(d.begin(),d.end());
  cout << d[N/2] - d[N/2-1] << endl;
}


Measured memory_bytes: 3792
N,M=map(int,input().split())

def kaijyou(k):
  N=1
  for i in range(k,0,-1):
    N*=i
  return N

def combinations(n,r):
  return int(kaijyou(n)/(kaijyou(r)*kaijyou(n-r)))

A=combinations(N,2)+combinations(M,2)
print(A)

Measured memory_bytes: 2940
import java.util.*;

public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    }
}

Measured memory_bytes: 23764
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			boolean flag = true;
			for (int j = 0; j < i; j++) {
				if (h[j] > h[i]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cnt++;
			}
		}

		pr.println(cnt);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23124
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;

import java.util.HashMap;

import java.util.StringTokenizer;



public class Main {

  public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

  static class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new
          InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String[] nextSArray() {
      String sr[] = null;
      try {
        sr = br.readLine().trim().split(" ");
      } catch (IOException e) {
        e.printStackTrace();
      }
      return sr;
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }

      return str;
    }
  }
  static long gcd(long a,long b)
  {
    if(a==0)
      return b;
    return  gcd(b%a,a);
  }

  //  static int MOD=1000000000+7;
  static BigInteger combination(long n,long k)
  {

    long kk=Math.min(n-k,k);
    BigInteger N=BigInteger.valueOf(n);
    //BigInteger K=BigInteger.valueOf(kk);
    BigInteger num=new BigInteger("1");
    BigInteger den =new BigInteger("1");
    BigInteger one =new BigInteger("1");

    for(int i=1;i<=kk;++i)
    {
     // num*=n;
      num=num.multiply(N);
      N=N.subtract(one);
      den=den.multiply(BigInteger.valueOf(i));
    }
    return num.divide(den);
  }

  static long mod=1000000007;
  public static void main(String[] args) throws Exception {
    FastReader sc = new FastReader();
    int n=sc.nextInt();
    out.println(n*(1+n*(1+n)));
    out.flush();
    out.close();
  }
}



// out.println(al.toString().replaceAll("[\\[|\\]|,]",""));


Measured memory_bytes: 32656
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };
ll a[200001];
int cnt[101];
int main()
{
	SYNC;
		int x, b;
		cin >> n >> x >> b;

		bool ok = 1;
		int ans = (n+x-1)/x * b;


		cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;

const int N = 8;
char grid[N][N];
int h, w, k;
int res;

void dfs(int r, int c)
{
  //cout << "r: " << r << ", c: " << c << endl;
  if(r == h && c == w)
  {
    int cnt = 0;
    for(int i = 0; i < h; ++i)
    {
      for(int j = 0; j < w; ++j)
      {
        //cout << grid[i][j] << " ";
        if(grid[i][j] == '#')
          cnt++;
      }
      //cout << endl;
    }
    if(cnt == k)
      res++;
    return;
  }
  
  if(r < h)
  {
    dfs(r+1, c);
    
    char r_copy[N];
    for(int j = 0; j < w; ++j)
    {
      r_copy[j] = grid[r][j];
      grid[r][j] = '0';
    }
    
    dfs(r+1, c);
    
    for(int j = 0; j < w; ++j)
    {
      grid[r][j] = r_copy[j];
    }
  }
  else if(c < w)
  {
    dfs(r, c+1);
    char c_copy[N];
    for(int i = 0; i < h; ++i)
    {
      c_copy[i] = grid[i][c];
      grid[i][c] = '0';
    }
    
    dfs(r, c+1);
    
    for(int i = 0; i < h; ++i)
    {
      grid[i][c] = c_copy[i];
    }
  }
    
}

int main()
{
  cin >> h >> w >> k;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      cin >> grid[i][j];
  
  dfs(0, 0);
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n,i,ans=0,x,k=1;
	cin>>n;
	for(i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(i=1;i<=n;++i)
	{
		if(a[i]!=k) ans++;
		else
		{
			k++;
		}
		if(i==n&&ans==n)
		{
			cout<<"-1";
			return 0;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define x first
#define ys second.first
#define yt second.second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 

struct node
{
	int num,l,r,ls,rs;
	node(int _l,int _r)
	{
		num=0;
		l=_l;
		r=_r;
	}
};

vector<node> T;
vector<ll> d;

int make(int l,int r)
{
	int id=T.size();
	T.push_back(node(l,r));
	T[id].ls=(l+1==r?-1:make(l,(l+r)/2));
	T[id].rs=(l+1==r?-1:make((l+r)/2,r));
	return id;
}

void update(int id,int l,int r,int t)
{
	if(l==r||T[id].l>=r||T[id].r<=l)
		return ;
	if(T[id].l>=l&&T[id].r<=r)
	{
		T[id].num+=t;
		return ;
	}
	int mid=(T[id].l+T[id].r)>>1;
	if(l<mid)
		update(T[id].ls,l,r,t);
	if(r>mid)
		update(T[id].rs,l,r,t);
	int mi=min(T[T[id].ls].num,T[T[id].rs].num);
	T[id].num+=mi;
	T[T[id].ls].num-=mi;
	T[T[id].rs].num-=mi;
}

ll gettot(int id)
{
	if(id==-1) return 0; 
	if(T[id].num>0)
	{
		//printf("|%d %d %d %d\n",T[id].l,T[id].r,d[T[id].l],d[T[id].r]);
		return d[T[id].r]-d[T[id].l];
	}
	return gettot(T[id].ls)+gettot(T[id].rs);
}

int main()
{
	//freopen("in.txt","r",stdin);
	T.reserve(50000);
	int n;
	scanf("%d",&n);
	set<int> s;
	priority_queue<pip,vector<pip>,greater<pip> > pq; 
	for(int i=0;i<n;i++)
	{
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		s.insert(y1);s.insert(y2);
		pq.push(make_pair(x1,make_pair(y1,y2)));
		pq.push(make_pair(x2,make_pair(y2,y1)));
	}
	map<int,int> y;
	d.clear();
	for(set<int>::iterator it=s.begin();it!=s.end();it++)
	{
		y[*it]=d.size();
		d.push_back(*it);
	}
	//printf("1");
	make(0,5000);
	//printf("2\n");
	//for(int i=0;i<T.size();i++) printf("%d %d %d %d %d %d\n",i,T[i].num,T[i].l,T[i].r,T[i].ls,T[i].rs);
	//for(int i=0;i<d.size();i++) printf("%d\n",d[i]);
	ll ans=0;
	while(true)
	{
		pip t=pq.top();pq.pop();
		if(pq.empty()) break;
		if(t.second.first<t.second.second)
		{
			//printf("%d %d\n",y[t.second.first],y[t.second.second]);
			update(0,y[t.second.first],y[t.second.second],1);
		}
		else
			update(0,y[t.second.second],y[t.second.first],-1);
		//for(int i=0;i<T.size();i++) printf("%d %d %d %d %d %d\n",i,T[i].num,T[i].l,T[i].r,T[i].ls,T[i].rs);
		//printf("||%d %d %d\n",gettot(0),t.x,pq.top().x);
		ans+=gettot(0)*(pq.top().x-t.x);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    int ans;
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
            ans++;
    }

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


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); 
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++)cin >> d[i];
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){sum+=d[i]*d[j];}
  }
  cout << sum << endl;
}

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

#define SIZE 300005

int N;		/* 2 ~ 3E5 */
char S[SIZE];
int resistor[SIZE]={0};
int min=0;

int main(){
#ifdef DEBUG
	printf("DEBUGGING ON\n");
#endif
	scanf("%d",&N);
	scanf("%s",S);
	for (int i=1;i<N;++i){
		if(S[i]=='E')resistor[0]+=1;
	}		/* The number of change if the leader was the zeroth man */
	min=resistor[0];
	int prechange=0,mychange=0;
	for (int i=1; i<N;++i){
		prechange=(S[i-1]=='W')?1:0;
		mychange=(S[i]=='E')?-1:0;
		resistor[i]=resistor[i-1]+prechange+mychange;
		if (resistor[i]<min) min = resistor[i];
	}
	printf("%d\n",min);
	return (0);
}

Measured memory_bytes: 1664
loop do
    n, x = gets.split.map(&:to_i)
    break if n == 0 && x == 0

    anscount = 0
    (1..(n - 2)).each do |a|
        ((a + 1)..(n - 1)).each do |b|
            ((b + 1)..n).each do |c|
                if a + b + c == x
                    anscount += 1
                end
            end
        end
    end
    puts anscount
end

Measured memory_bytes: 8768
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
template<unsigned MOD_> struct ModInt {
    static constexpr unsigned MOD = MOD_;
    unsigned x;
    void undef() { x = (unsigned)-1; }
    bool isnan() const { return x == (unsigned)-1; }
    inline int geti() const { return (int)x; }
    ModInt() { x = 0; }
    ModInt(const ModInt &y) { x = y.x; }
    ModInt(int y) { if (y<0 || (int)MOD<=y) y %= (int)MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt(long long y) { if (y<0 || MOD<=y) y %= MOD; if (y<0) y += MOD; x=y; }
    ModInt(unsigned long long y) { if (MOD<=y) x = y % MOD; else x = y; }
    ModInt &operator+=(const ModInt y) { if ((x += y.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(const ModInt y) { if ((x -= y.x) & (1u<<31)) x += MOD; return *this; }
    ModInt &operator*=(const ModInt y) { x = (unsigned long long)x * y.x % MOD; return *this; }
    ModInt &operator/=(const ModInt y) { x = (unsigned long long)x * y.inv().x % MOD; return *this; }
    ModInt operator-() const { return (x ? MOD-x: 0); }

    ModInt inv() const { return pow(MOD-2); }
    ModInt pow(long long y) const {
	ModInt b = *this, r = 1;
	if (y < 0) { b = b.inv(); y = -y; }
	for (; y; y>>=1) {
	    if (y&1) r *= b;
	    b *= b;
	}
	return r;
    }

    friend ModInt operator+(ModInt x, const ModInt y) { return x += y; }
    friend ModInt operator-(ModInt x, const ModInt y) { return x -= y; }
    friend ModInt operator*(ModInt x, const ModInt y) { return x *= y; }
    friend ModInt operator/(ModInt x, const ModInt y) { return x *= y.inv(); }
    friend bool operator<(const ModInt x, const ModInt y) { return x.x < y.x; }
    friend bool operator==(const ModInt x, const ModInt y) { return x.x == y.x; }
    friend bool operator!=(const ModInt x, const ModInt y) { return x.x != y.x; }
};

constexpr LL MOD = 998244353;
using Mint = ModInt<MOD>;

Mint dp[3011][3011];
int A, B, C, D;


void MAIN() {
    scanf("%d%d%d%d", &A, &B, &C, &D);
    dp[A][B] = 1;
    REP (i, C+1) REP (j, D+1) if (dp[i][j].x) {
	dp[i+1][j] += dp[i][j] * j;
	dp[i][j+1] += dp[i][j] * i;
	dp[i+1][j+1] -= dp[i][j] * i * j;
    }

    Mint ans = dp[C][D];
    printf("%d\n", ans.geti());
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 39224
#include<bits/stdc++.h>
using namespace std;
int k;
vector<long long> v;

void f(int id, long long num, int prev) {
    if (id == 10) {
        return;
    }

    for (int k = -1; k <= 1; k++) {
        int x = prev + k;
        if (x < 0 || x > 9) continue;
        num = num * 10 + x;
        v.emplace_back(num);
        f(id + 1, num, x);
        num /= 10;
    }
}

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    for (int i = 1; i < 10; i++) {
        v.emplace_back(i);
        f(1, i, i);
    }

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

    cin >> k;
    cout << v[k - 1] << '\n';
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;

int main(){
	cin>>n>>k;
	int t=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(x>=k) t++;
	}
	cout<<t<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1)%LEN;
}

P dequeue(void){
  P x = Q[head];
  head = (head+1)%LEN;
  return x;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n+1;

  while(head != tail){
    u = dequeue();
    if(q<u.t){
      c = q;
    }else{
      c = u.t;
    }
    u.t = u.t-c;
    elaps = elaps+c;
    if(u.t>0){
      enqueue(u);
    }else{
      printf("%s %d\n",u.name,elaps);
    }
  }

  
  return 0;
}



Measured memory_bytes: 11888
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <queue>
#include <map>
#include <string>
#define INF 99999999
using namespace std;
const int MAXN = 505;

int main(){
    char s1[5];
    char s2[5];
    cin >> s1;
    cin >> s2;
    for(int i=0;i<3;i++){
        if(s1[i] != s2[2-i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int x;
    for (int i = 1; i <= 5; ++i) {
        cin >> x;
        if (x == 0)
            cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
program main

  implicit none
  integer(8) :: a, b, n

  integer(8) :: tmp
  
  read(*,*) n, a, b
  
  tmp = n / ( a + b )
  
  if ( mod( n, (a+b) ) <= a ) then
    print*, tmp * a + mod( n, (a+b) )
  else
    print*, (tmp+1) * a 
  end if

end program main


Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>
#define mod % 2019
typedef long long ll;

int main(void) {
  ll i, j, k, l, r, n, ans = 2018;
  scanf("%lld%lld", &l, &r);
  n = l + 2019;
  if(n > ++r) n = r;
  for(i = l; i < n; ++i) for(j = i + 1; j < n; ++j) if((i * j) mod < ans) ans = (i * j) mod;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second
#define pb push_back 
#define pf push_front 
#define ppb pop_back 
#define ppf pop_front 

using namespace std ;
 
ll z , o , ans ;
 
int main(){
 

	int n ;

	cin >> n ;

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

		if( i % 3 == 0 || i % 5 == 0 ){

			continue ;

		}

		else{

			ans += i ;

		}

	}

	cout << ans ;

 
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  bool good = false;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int num = i * m + j * (n - i) - j * i;
      if (num == k) {
        good = true;
        break;
      }
    }
  }
  if (good) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

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

int main() {
  double a;
  int b;
  cin>>a>>b;
  int ans=-1;
  for(int p=10*b; p<10*b+10; p++){
    if(25*a/2<=p && p<25*(a+1)/2){
      ans=p;break;}
  }
  cout<<ans;
}

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

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		string w = cin.next();
		int[] num = new int[26];
		for (int i = 0; i < w.Length; i++)
		{
			num[w[i] - 'a']++;
		}
		for (int i = 0; i < 26; i++)
		{
			if (num[i] % 2 == 1)
			{
				Console.WriteLine("No");
				return;
			}
		}
		Console.WriteLine("Yes");
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    while (1)
    {
        if (n % 111 == 0)
            break;
        ++n;
    }
    cout << n << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 305

enum Type{
	EVEN,
	ODD,
};

ll D,S;
ll table[SIZE];
int dp[2][SIZE][SIZE*SIZE];
Type rev_type[2] = {ODD,EVEN};


ll mod_pow(ll x,ll n, ll mod){

	if(n == 0)return 1;
	ll ret = mod_pow(x*x%mod,n/2,mod);
	if(n%2 == 1)ret = ret*x%mod;
	return ret;
}

int recursive(int dim,int rest,Type type){

	if(dp[type][dim][rest] != -1){

		return dp[type][dim][rest];
	}
	ll ret = 0;

	if(dim == D){

		ret = mod_pow(rest,D,MOD);
		if(type == ODD)ret *= -1;

		if(ret < 0){
			ret += MOD;
		}

	}else{

		ret += recursive(dim+1,rest,type);
		ret %= MOD;

		if(rest >= table[dim]){

			ret += recursive(dim+1,rest-table[dim],rev_type[type]);
			ret %= MOD;
		}
	}

	return dp[type][dim][rest] = (int)ret;
}

int main(){

	scanf("%lld",&D);

	for(int i = 0; i < D; i++){

		scanf("%lld",&table[i]);
	}

	scanf("%lld",&S);

	for(int i = 0; i < 2; i++){
		for(int a = 0; a <= D; a++){
			for(int b = 0; b <= S; b++){
				dp[i][a][b] = -1;
			}
		}
	}

	printf("%d\n",recursive(0,S,EVEN));

	return 0;
}



Measured memory_bytes: 217240
n = int(input())
gu = [ int(i) for i in input().split(" ") ]
gu.sort()

def mix( a, b ):
  return ( a + b ) / 2.0

v = mix( gu[0], gu[1])
for i in range( 2, len( gu )):
  v = mix( gu[i], v )

print(v)

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

S = int(input())

s1 = S//100
s2 = S%100

yymm = 1<=s2<=12
mmyy = 1<=s1<=12

ans = ""
if yymm:
    if mmyy:
        ans = "AMBIGUOUS"
    else:
        ans = "YYMM"
else:
    if mmyy:
        ans = "MMYY"
    else:
        ans = "NA"

print(ans)

Measured memory_bytes: 3060